librato-metrics
Advanced tools
Comparing version 0.0.1 to 0.0.3
@@ -0,3 +1,4 @@ | ||
var util = require('util'); | ||
var request = require('request'); | ||
var url = require('url'); | ||
var url = require('url'); | ||
@@ -32,23 +33,34 @@ module.exports = Client; | ||
Client.prototype.request = function(options, cb) { | ||
var uri = url.parse(this._endpoint); | ||
uri.auth = this.email + ':' + this.token; | ||
uri = url.format(uri) + options.path; | ||
var requestOptions = { | ||
method : options.method, | ||
uri : uri, | ||
json : options.json, | ||
method : options.method, | ||
uri : this._endpoint + options.path, | ||
json : options.json, | ||
headers : { | ||
authorization: this._authorization(), | ||
}, | ||
}; | ||
request(requestOptions, function(err, response, body) { | ||
if (body) { | ||
try{ | ||
body = JSON.parse(body) | ||
} catch (_err) { | ||
return cb(_err); | ||
} | ||
var code = response.statusCode; | ||
if (!err && ((body && body.errors) || code > 399)) { | ||
err = new Error( | ||
'LibratoMetrics.Error: ' + | ||
util.inspect(body) + | ||
' (statusCode: ' + code + ')' | ||
); | ||
} | ||
try{ | ||
if (body) body = JSON.parse(body); | ||
} catch (_err) { | ||
if (!err) err = _err; | ||
} | ||
cb(err, body); | ||
}); | ||
}; | ||
Client.prototype._authorization = function() { | ||
var credentials = this.email + ':' + this.token; | ||
return 'Basic ' + new Buffer(credentials).toString('base64'); | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"description": "A node module for sending data to librato metrics.", | ||
"version": "0.0.1", | ||
"version": "0.0.3", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -21,4 +21,5 @@ var assert = require('assert'); | ||
console.log(response); | ||
assert.equal(response.name, metricName); | ||
}); | ||
}); |
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 5 instances in 1 package
924804
75
1
7