Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
404e362
Let and Const all the things :hammer_and_wrench:
AdrieanKhisbe Mar 1, 2019
45649fc
Massive refactor trying to have instantiable client :hammer_and_pick:
AdrieanKhisbe Mar 1, 2019
9c26fa9
Add some tweaks methods to keep initial api working :hammer_and_pick:
AdrieanKhisbe Mar 1, 2019
07613ae
Add two examples file with the original and new api :bookmark_tabs:
AdrieanKhisbe Mar 1, 2019
e501868
Set up linting configuration :gear:
AdrieanKhisbe Mar 5, 2019
8330337
Reformating with the new prettier configuration :wrench:
AdrieanKhisbe Mar 5, 2019
0dbab0c
Make linting green again :white_check_mark:
AdrieanKhisbe Mar 5, 2019
b971434
Make linting green again for all files, not just lib :green_book:
AdrieanKhisbe Mar 5, 2019
f1cbac8
Configure travis to make lint run :traffic_light:
AdrieanKhisbe Mar 5, 2019
9785317
Specify engine and drop support of node 4/5 :rotating_light:
AdrieanKhisbe Mar 5, 2019
4d1cc5d
Set up coverage reports :shield:
AdrieanKhisbe Mar 8, 2019
449180b
Tune coverage setting and reports :spiral_notepad:
AdrieanKhisbe Mar 8, 2019
34c3930
Add coverage badge to the README :name_badge:
AdrieanKhisbe Mar 8, 2019
1df6286
Rename packages and warning in README
AdrieanKhisbe Oct 11, 2019
4c70d9a
Reorganise a bit the repository :file_cabinet:
AdrieanKhisbe Oct 11, 2019
95d46d3
Extract license from README :balance_scale:
AdrieanKhisbe Oct 11, 2019
6681895
Update tested version on npm to reflect new lts :vertical_traffic_light:
AdrieanKhisbe Oct 11, 2019
a2ce6d5
Add some npmignore for future publications :see_no_evil:
AdrieanKhisbe Oct 11, 2019
7afaeac
Rewire together package post to package reorg :paperclips:
AdrieanKhisbe Oct 11, 2019
38190f9
Refactoring constant and bin/cli :hammer_and_wrench:
AdrieanKhisbe Oct 11, 2019
d0774fc
Set node v8.10 as minimal engine :8ball:
AdrieanKhisbe Oct 11, 2019
9bd34bf
Directly use library json-bigint :clamp:
AdrieanKhisbe Oct 11, 2019
12eecf5
Convert tests to ava :rocket:
AdrieanKhisbe Oct 11, 2019
c0d3657
Replace stubing by spying so that test can be parallel :detective:
AdrieanKhisbe Oct 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
test/coverage/
38 changes: 38 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"env": {
"commonjs": true,
"es6": true,
"node": true
},
"extends": [
"plugin:@coorpacademy/coorpacademy/core",
"plugin:@coorpacademy/coorpacademy/ava",
"plugin:@coorpacademy/coorpacademy/es20XX",
"plugin:@coorpacademy/coorpacademy/lodash-fp",
"plugin:@coorpacademy/coorpacademy/prettier"
],
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"plugins": [
"@coorpacademy/coorpacademy"
],
"rules": {
"promise/no-native": "off",
"strict": "off",
"fp/no-arguments": "warn",
"no-param-reassign": "warn",
"prefer-rest-params": "warn",
"fp/no-loops": "warn"
},
"overrides": [
{
"files": [ "bin/*" ],
"rules": {
"no-console": "off",
"no-continue": "warn"
}
}
]
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ results
npm-debug.log

.dogapirc

.nyc_output
coverage.lcov
coverage
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
documentation
scripts
.eslintrc
.eslintignore
.travis.yml
tmp
private
examples
19 changes: 19 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"all": true,
"reporter": [
"html",
"lcov",
"text",
"text-summary"
],
"report-dir": "./coverage",
"include": [
"src/**/*.js"
],
"exclude": [
"test/**/*",
"examples/"
],
"cache": true
}

16 changes: 11 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
language: node_js
node_js:
- "4"
- "5"
- "6"
- "7"
- "8"
- "9"
- "10"
- "12"
- "node"

install:
- npm install

script:
- npm run lint
- npm run cover

after_success:
- npm run publish-coverage
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2013 Brett Langdon <me@brett.is>
Copyright (c) 2019 Adriean Khisbe


Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.
30 changes: 12 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
dogapi
======
datadog-client
==============

> Datadog API Node.JS Client.

:warning: This is a fork from [node-dogapi](https://github.com/brettlangdon/node-dogapi)

**README does not yet fully reflect that!**

[![npm version](https://badge.fury.io/js/dogapi.svg)](https://www.npmjs.com/package/dogapi)
[![Build Status](https://travis-ci.org/brettlangdon/node-dogapi.svg?branch=master)](https://travis-ci.org/brettlangdon/node-dogapi)
[![Dependency Status](https://david-dm.org/brettlangdon/node-dogapi.svg)](https://david-dm.org/brettlangdon/node-dogapi)
[![codecov](https://codecov.io/gh/brettlangdon/node-dogapi/branch/master/graph/badge.svg)](https://codecov.io/gh/brettlangdon/node-dogapi)

Datadog API Node.JS Client.

Official Datadog API Documentation: http://docs.datadoghq.com/api/

dogapi API Docs: http://brettlangdon.github.io/node-dogapi/
# Documentation :books:
- Official Datadog API Documentation: http://docs.datadoghq.com/api/
- Original `dogapi` API Docs: http://brettlangdon.github.io/node-dogapi/

## StatsD

Expand Down Expand Up @@ -159,14 +164,3 @@ var metrics = [
];
dogapi.metric.send_all(metrics);
```

## License

The MIT License (MIT)
Copyright (c) 2013 Brett Langdon <me@brett.is>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
126 changes: 57 additions & 69 deletions bin/dogapi
Original file line number Diff line number Diff line change
@@ -1,81 +1,69 @@
#!/usr/bin/env node
var dogapi = require("../");
var json = require("../lib/json");
var minimist = require("minimist");
var rc = require("rc");
var EOL = require("os").EOL;
const dogapi = require('..');
const _ = require('lodash/fp');
const json = require('json-bigint');
const minimist = require('minimist');
const rc = require('rc');
const {EOL} = require('os');
const {version} = require('../package');

var config = rc("dogapi", {
api_key: null,
app_key: null
});
const config = rc('dogapi', {api_key: null, app_key: null});
dogapi.initialize(config);

var usage = [
"Usage:",
" dogapi --help",
" dogapi <command> --help",
" dogapi --version",
" dogapi now",
" dogapi past <seconds-ago>",
" dogapi future <seconds-ahead>"
];
var help = [];
for(var key in dogapi){
if(!dogapi.hasOwnProperty(key)){
continue;
} else if(!dogapi[key].hasOwnProperty("getUsage") || typeof dogapi[key].getUsage !== "function"){
continue;
} else if(!dogapi[key].hasOwnProperty("handleCli") || typeof dogapi[key].handleCli !== "function"){
continue;
}
usage = usage.concat(dogapi[key].getUsage());
const hasKey = (key, functionName) =>
_.hasOwnProperty(functionName, dogapi[key]) && _.isFunction(_.get([key, functionName], dogapi));

if(dogapi[key].hasOwnProperty("getHelp") && typeof dogapi[key].getHelp === "function"){
help = help.concat([""], dogapi[key].getHelp());
}
}
const usage = [
'Usage:',
' dogapi --help',
' dogapi <command> --help',
' dogapi --version',
' dogapi now',
' dogapi past <seconds-ago>',
' dogapi future <seconds-ahead>'
];
const help = [];
_.keys(dogapi).forEach(key => {
if (!hasKey(key, 'getUsage') || hasKey(key, 'handleCli')) return;
usage.push(...dogapi[key].getUsage());
if (hasKey(key, 'getHelp')) help.push('', ...dogapi[key].getHelp());
});

usage = usage.concat(help);
usage = usage.join(EOL);
var args = minimist(process.argv);
usage.push(...help);

var command = args._[2];
var subcommand = args._[3];
const main = args => {
const command = args._[2] === 'servicecheck' ? 'serviceCheck' : args._[2];
const subcommand = args._[3];

// this is the one unusual case
if(command === "servicecheck"){
command = "serviceCheck";
}
if (command === 'now') return console.log(dogapi.now());
if (command === 'past' && args._.length > 3)
return console.log(dogapi.now() - parseInt(args._[args._.length - 1]));
if (command === 'future' && args._.length > 3)
return console.log(dogapi.now() + parseInt(args._[args._.length - 1]));

if(command === "now"){
console.log(dogapi.now());
} else if(command === "past" && args._.length > 3){
console.log(dogapi.now() - parseInt(args._[args._.length - 1]));
} else if(command === "future" && args._.length > 3){
console.log(dogapi.now() + parseInt(args._[args._.length - 1]));
} else if(dogapi.hasOwnProperty(command)){
if(subcommand){
dogapi[command].handleCli(subcommand, args, function(err, res){
if(err){
console.error(json.stringify(err, null, ' '));
process.exit(1);
} else {
if(res === ""){
res = "success";
}
console.log(json.stringify(res, null, ' '));
}
});
} else {
var commandUsage = ["Usage:"].concat(dogapi[command].getUsage());
if(dogapi[command].hasOwnProperty("getHelp") && typeof dogapi[command].getHelp === "function"){
commandUsage = commandUsage.concat([EOL], dogapi[command].getHelp());
if (dogapi.hasOwnProperty(command)) {
if (subcommand) {
dogapi[command].handleCli(subcommand, args, function(err, res) {
if (err) {
console.error(json.stringify(err, null, ' '));
process.exit(1);
}
console.log(commandUsage.join(EOL).replace(/\$\{command\}/g, " dogapi"));
return console.log(json.stringify(res || 'success', null, ' '));
});
}

let commandUsage = ['Usage:'].concat(dogapi[command].getUsage());
if (hasKey(command, 'getHelp')) {
commandUsage = commandUsage.concat([EOL], dogapi[command].getHelp());
}
} else if(args.version){
console.log(require("../package.json").version);
} else {
console.log(usage);
return console.log(commandUsage.join(EOL).replace(/\$\{command\}/g, ' dogapi'));
}
if (args.version) return console.log(version);

console.log(usage.join(EOL));
};

if (!module.parent) {
const args = minimist(process.argv);
main(args);
}
File renamed without changes.
10 changes: 10 additions & 0 deletions examples/new-interface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const Dogapi = require('../src'); // use 'datadog-client' instead

const options = {
api_key: 'YOUR_KEY_HERE',
app_key: 'YOUR_KEY_HERE'
};

const dogapi = new Dogapi(options);

dogapi.metric.send('test', 1);
10 changes: 10 additions & 0 deletions examples/original-interface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const dogapi = require('../src'); // use 'datadog-client' instead

const options = {
api_key: 'YOUR_KEY_HERE',
app_key: 'YOUR_KEY_HERE'
};

dogapi.initialize(options);

dogapi.metric.send('test', 1);
Loading