Browse Source

Add some tweaks methods to keep initial api working ⚒️

pull/61/head
AdrieanKhisbe 7 years ago
parent
commit
9c26fa9671
2 changed files with 13 additions and 16 deletions
  1. +1
    -9
      lib/api/index.js
  2. +12
    -7
      lib/index.js

+ 1
- 9
lib/api/index.js View File

@ -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;

+ 12
- 7
lib/index.js View File

@ -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;


Loading…
Cancel
Save