From 9c26fa96713f9aebcffa45b774303f91af51c107 Mon Sep 17 00:00:00 2001 From: AdrieanKhisbe Date: Fri, 1 Mar 2019 18:12:33 +0100 Subject: [PATCH] Add some tweaks methods to keep initial api working :hammer_and_pick: --- lib/api/index.js | 10 +--------- lib/index.js | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/api/index.js b/lib/api/index.js index 41a315b..cc81266 100644 --- a/lib/api/index.js +++ b/lib/api/index.js @@ -1,4 +1,4 @@ -const api = { +module.exports = { comment: require("./comment"), downtime: require("./downtime"), embed: require("./embed"), @@ -15,11 +15,3 @@ const api = { timeboard: require("./timeboard"), user: require("./user"), }; - -module.exports = function(obj){ - for(const key in api){ - obj[key] = api[key]; - } -}; - -module.exports.api = api; diff --git a/lib/index.js b/lib/index.js index e0007bb..8e1266b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,7 +1,8 @@ -const _ = require('lodash') -const api = require("./api").api; +const _ = require('lodash'); +const api = require("./api"); const Client = require("./client"); +const initialClient = new Client({}) /*section: dogapi *comment: configure the dogapi client with your app/api keys *params: @@ -41,8 +42,8 @@ const Client = require("./client"); function initialize(options){ options = options || {}; for(var key in options){ - if(module.exports.client.hasOwnProperty(key)){ - module.exports.client[key] = options[key]; + if(initialClient.hasOwnProperty(key)){ + initialClient[key] = options[key]; } } }; @@ -50,10 +51,15 @@ function initialize(options){ function DogApi(options) { const client = new Client(options || {}); _.forEach(api, (value, key) => { - this[key] = value(client) + this[key] = value(client); }); } +DogApi.initialize = initialize; +_.forEach(api, (value, key) => { + DogApi[key] = value(initialClient); +}); + /*section: dogapi *comment: get the current POSIX timestamp *example: | @@ -67,8 +73,7 @@ function DogApi(options) { function now(){ return parseInt(new Date().getTime() / 1000); }; -module.exports = DogApi -module.exports.initialize = initialize; +module.exports = DogApi; module.exports.now = now; module.exports.OK = 0; module.exports.WARNING = 1;