diff --git a/src/apptask.js b/src/apptask.js index 5a3b44876..5c932e251 100644 --- a/src/apptask.js +++ b/src/apptask.js @@ -51,7 +51,7 @@ var addons = require('./addons.js'), paths = require('./paths.js'), safe = require('safetydance'), shell = require('./shell.js'), - SubdomainError = require('./subdomainerror.js'), + SubdomainError = require('./subdomains.js').SubdomainError, subdomains = require('./subdomains.js'), superagent = require('superagent'), sysinfo = require('./sysinfo.js'), diff --git a/src/aws.js b/src/aws.js index 213937344..0df73b812 100644 --- a/src/aws.js +++ b/src/aws.js @@ -13,7 +13,7 @@ var assert = require('assert'), AWS = require('aws-sdk'), config = require('./config.js'), debug = require('debug')('box:aws'), - SubdomainError = require('./subdomainerror.js'), + SubdomainError = require('./subdomains.js').SubdomainError, superagent = require('superagent'); function getBackupCredentials(callback) { diff --git a/src/dns/caas.js b/src/dns/caas.js index f3f5179a1..f9bb61f19 100644 --- a/src/dns/caas.js +++ b/src/dns/caas.js @@ -13,7 +13,7 @@ exports = module.exports = { var assert = require('assert'), config = require('../config.js'), debug = require('debug')('box:dns/caas'), - SubdomainError = require('../subdomainerror.js'), + SubdomainError = require('../subdomains.js').SubdomainError, superagent = require('superagent'), util = require('util'), _ = require('underscore'); diff --git a/src/dns/route53.js b/src/dns/route53.js index 1be64c6ef..3a3aa1b51 100644 --- a/src/dns/route53.js +++ b/src/dns/route53.js @@ -15,7 +15,7 @@ var assert = require('assert'), config = require('../config.js'), debug = require('debug')('box:dns/route53'), settings = require('../settings.js'), - SubdomainError = require('../subdomainerror.js'), + SubdomainError = require('../subdomains.js').SubdomainError, util = require('util'), _ = require('underscore'); diff --git a/src/subdomainerror.js b/src/subdomainerror.js deleted file mode 100644 index 85d011b73..000000000 --- a/src/subdomainerror.js +++ /dev/null @@ -1,33 +0,0 @@ -/* jslint node:true */ - -'use strict'; - -var assert = require('assert'), - util = require('util'); - -exports = module.exports = SubdomainError; - -function SubdomainError(reason, errorOrMessage) { - assert.strictEqual(typeof reason, 'string'); - assert(errorOrMessage instanceof Error || typeof errorOrMessage === 'string' || typeof errorOrMessage === 'undefined'); - - Error.call(this); - Error.captureStackTrace(this, this.constructor); - - this.name = this.constructor.name; - this.reason = reason; - if (typeof errorOrMessage === 'undefined') { - this.message = reason; - } else if (typeof errorOrMessage === 'string') { - this.message = errorOrMessage; - } else { - this.message = 'Internal error'; - this.nestedError = errorOrMessage; - } -} -util.inherits(SubdomainError, Error); - -SubdomainError.NOT_FOUND = 'No such domain'; -SubdomainError.EXTERNAL_ERROR = 'External error'; -SubdomainError.STILL_BUSY = 'Still busy'; -SubdomainError.MISSING_CREDENTIALS = 'Missing credentials'; diff --git a/src/subdomains.js b/src/subdomains.js index dae19dbdc..e914fb4c0 100644 --- a/src/subdomains.js +++ b/src/subdomains.js @@ -2,21 +2,47 @@ 'use strict'; -var assert = require('assert'), - caas = require('./dns/caas.js'), - config = require('./config.js'), - route53 = require('./dns/route53.js'), - SubdomainError = require('./subdomainerror.js'), - util = require('util'); - module.exports = exports = { add: add, remove: remove, status: status, update: update, // unlike add, this fetches latest value, compares and adds if necessary. atomicity depends on backend - get: get + get: get, + + SubdomainError: SubdomainError }; +var assert = require('assert'), + caas = require('./dns/caas.js'), + config = require('./config.js'), + route53 = require('./dns/route53.js'), + util = require('util'); + +function SubdomainError(reason, errorOrMessage) { + assert.strictEqual(typeof reason, 'string'); + assert(errorOrMessage instanceof Error || typeof errorOrMessage === 'string' || typeof errorOrMessage === 'undefined'); + + Error.call(this); + Error.captureStackTrace(this, this.constructor); + + this.name = this.constructor.name; + this.reason = reason; + if (typeof errorOrMessage === 'undefined') { + this.message = reason; + } else if (typeof errorOrMessage === 'string') { + this.message = errorOrMessage; + } else { + this.message = 'Internal error'; + this.nestedError = errorOrMessage; + } +} +util.inherits(SubdomainError, Error); + +SubdomainError.NOT_FOUND = 'No such domain'; +SubdomainError.EXTERNAL_ERROR = 'External error'; +SubdomainError.STILL_BUSY = 'Still busy'; +SubdomainError.MISSING_CREDENTIALS = 'Missing credentials'; + // choose which subdomain backend we use for test purpose we use route53 function api() { return config.isCustomDomain() || config.TEST ? route53 : caas;