 jraphical = require 'jraphical'
-DomainManager = require 'domainer'
-{secure, ObjectId}  = require 'bongo'
+module.exports = class JDomain extends jraphical.Module
 
-module.exports = class JDomain extends jraphical.Module
+  DomainManager = require 'domainer'
+  {secure, ObjectId}  = require 'bongo'
+
 
   domainManager = new DomainManager
   JAccount  = require './account'



  @addNewDNSRecord = secure ({connection:{delegate}}, data, callback)->
    newRecord = 
      mode          : "vm"
      username      : delegate.profile.nickname
      domainName    : data.domainName
      linkedVM      : data.selectedVM

    domainManager.dnsManager.registerNewRecordToProxy newRecord, (response)=>
      domain = 
        domain       : newRecord.domainName
        orderId      : "0" # when forwarding we got no orderid
        linkURL      : newRecord.domainName

      username      : client.context.user
      domainName : data.domainName
      mode          : "vm"

    # not working should talk with farslan
    domainManager.dnsManager.removeDNSRecordFromProxy record, callback

  @bindVM = secure ({connection:{delegate}}, params, callback)->
    record =
      mode          : "vm"
      username      : delegate.profile.nickname
      domainName    : params.domainName
