Skip to content

Commit

Permalink
Merge pull request #20 from mileszim/update-depedencies
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
mileszim authored Oct 19, 2018
2 parents f370643 + 495d007 commit 3bd4b31
Show file tree
Hide file tree
Showing 14 changed files with 3,375 additions and 2,031 deletions.
4 changes: 1 addition & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"presets": [
["env", {
"targets": { "node": "current" } }
]
["@babel/preset-env", { "targets": { "node": "current" } }]
],
"comments": false,
"minified": false
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules/
dist/

# Misc
.DS_Store
Expand Down
4 changes: 0 additions & 4 deletions .travis.yml
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
Expand Down
81 changes: 81 additions & 0 deletions dist/configuration.js
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;
7 changes: 7 additions & 0 deletions dist/index.js
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;
Loading

0 comments on commit 3bd4b31

Please sign in to comment.