-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from mileszim/update-depedencies
Update dependencies
- Loading branch information
Showing
14 changed files
with
3,375 additions
and
2,031 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
node_modules/ | ||
dist/ | ||
|
||
# Misc | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- "4" | ||
- "5" | ||
- "6" | ||
- "7" | ||
- "8" | ||
- "9" | ||
- "10" | ||
install: npm install | ||
script: npm test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.API_HOSTS = void 0; | ||
const API_PATH = '/services/rest/'; | ||
const API_HOSTS = { | ||
us: 'api1.webpurify.com', | ||
eu: 'api1-eu.webpurify.com', | ||
ap: 'api1-ap.webpurify.com', | ||
im: 'im-api1.webpurify.com', | ||
vid: 'vid-api1.webpurify.com' | ||
}; | ||
exports.API_HOSTS = API_HOSTS; | ||
const ENV = { | ||
api_key: process.env.WEBPURIFY_API_KEY, | ||
endpoint: process.env.WEBPURIFY_ENDPOINT, | ||
enterprise: process.env.WEBPURIFY_ENTERPRISE | ||
}; | ||
const DEFAULT_PARAMS = { | ||
endpoint: 'us', | ||
enterprise: false | ||
}; | ||
|
||
class Configuration { | ||
constructor(params = {}) { | ||
if (!(params instanceof Object)) { | ||
throw new Error('Invalid params - object required'); | ||
} | ||
|
||
this.params = params; | ||
} | ||
|
||
get config() { | ||
if (!this._options) { | ||
this._config = { | ||
api_key: this.api_key, | ||
endpoint: this.endpoint, | ||
enterprise: this.enterprise | ||
}; | ||
} | ||
|
||
return this._config; | ||
} | ||
|
||
get api_key() { | ||
const key = ENV.WEBPURIFY_API_KEY || this.params.api_key; | ||
|
||
if (!key) { | ||
throw new Error('api_key is a required parameter'); | ||
} | ||
|
||
if (typeof key !== 'string') { | ||
throw new Error('param.api_key must be of type string'); | ||
} | ||
|
||
return key; | ||
} | ||
|
||
get endpoint() { | ||
const hosts = Object.keys(API_HOSTS); | ||
const params_endpoint = hosts.includes(this.params.endpoint) || this.params.endpoint; | ||
const env_endpoint = hosts.includes(ENV.endpoint) || ENV.endpoint; | ||
return API_HOSTS[params_endpoint || env_endpoint || DEFAULT_PARAMS.endpoint]; | ||
} | ||
|
||
get enterprise() { | ||
const bools = ['true', 'false']; | ||
const params_enterprise = this.params.enterprise && bools.includes(this.params.enterprise.toString()) || this.params.enterprise; | ||
const env_enterprise = ENV.enterprise && bools.includes(ENV.enterprise.toString()) || ENV.enterprise; | ||
return params_enterprise || env_enterprise || DEFAULT_PARAMS.enterprise; | ||
} | ||
|
||
get path() { | ||
return API_PATH; | ||
} | ||
|
||
} | ||
|
||
exports.default = Configuration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict"; | ||
|
||
var _webpurify = _interopRequireDefault(require("./webpurify")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
module.exports = _webpurify.default; |
Oops, something went wrong.