eh-api-client
Advanced tools
Comparing version 0.9.0 to 0.10.0
31
index.js
@@ -62,2 +62,3 @@ var | ||
var deferred = Q.defer(); | ||
var self = this; | ||
if(typeof body === "function") { | ||
@@ -143,3 +144,3 @@ cb = body; | ||
} | ||
var req = request(reqParams, function(err, res, data) { | ||
var req = self._makeRequest(reqParams, function(err, res, data) { | ||
_res = res; | ||
@@ -166,2 +167,6 @@ if(err) { | ||
Client.prototype._makeRequest = function() { | ||
return request.apply(this, arguments); | ||
}; | ||
Client.prototype.release = function(cb) { | ||
@@ -176,2 +181,19 @@ this.delete("/locks/" + this.lockUUID, function(err, data) { | ||
Client.prototype.exists = function(url, options, cb) { | ||
if(typeof options === "function") { | ||
cb = options; | ||
options = null; | ||
} | ||
return this.request("head", url, options).then(function() { | ||
return true; | ||
}).catch(function(err) { | ||
if(err) { | ||
if(err.httpStatus === 404) { | ||
return false; | ||
} | ||
throw err; | ||
} | ||
}).nodeify(cb); | ||
}; | ||
methods.forEach(function(method) { | ||
@@ -189,2 +211,9 @@ Client.prototype[method.toLowerCase()] = function() { | ||
Factory.Client = Client; | ||
Factory.prototype.exists = function() { | ||
var c = new Client(this.apiURL); | ||
return c.exists.apply(c, arguments); | ||
}; | ||
methods.forEach(function(method) { | ||
@@ -191,0 +220,0 @@ Factory.prototype[method.toLowerCase()] = function() { |
{ | ||
"name": "eh-api-client", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "Node.js rest client", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha test" | ||
}, | ||
@@ -22,4 +22,5 @@ "repository": { | ||
"eh-guid": "^0.2.0", | ||
"should": "^6.0.3" | ||
"should": "^6.0.3", | ||
"sinon": "^1.15.4" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
12527
5
451
2
3