eh-api-client
Advanced tools
Comparing version 0.18.0 to 0.19.0
@@ -18,2 +18,5 @@ var | ||
}); | ||
this.requestOptions = { | ||
timeout: 300000 | ||
}; | ||
this.Client = getClientClass(); | ||
@@ -32,5 +35,9 @@ }; | ||
Factory.prototype.setRequestOptions = function(options) { | ||
_.extend(this.requestOptions, options); | ||
}; | ||
Factory.prototype.setAgentOptions = function(options) { | ||
_.defaults(options, {keepAlive: true}); | ||
self.agent = new Agent(options); | ||
this.agent = new Agent(options); | ||
}; | ||
@@ -37,0 +44,0 @@ |
@@ -43,5 +43,16 @@ var | ||
} | ||
if(error.httpStatus >= 500 && error.httpStatus < 600 && !error.hasOwnProperty("name")) { | ||
error.name = "ServerError"; | ||
} | ||
return error; | ||
} | ||
function buildNetworkError(res, origErr, url, method) { | ||
var error = new Error(); | ||
error.httpURL = url; | ||
error.name = "NetworkError"; | ||
error.message = origErr.code; | ||
return error; | ||
} | ||
module.exports = function() { | ||
@@ -145,3 +156,3 @@ var Client = function(apiURL, options) { | ||
if(err) { | ||
return deferred.reject(err); | ||
return deferred.reject(buildNetworkError(res, err, reqParams.url, method)); | ||
} | ||
@@ -168,2 +179,3 @@ if(res.statusCode < 200 || res.statusCode >= 300) { | ||
_.extend(params, this._factory.retryOptions); | ||
_.extend(params, this._factory.requestOptions); | ||
return request(params, cb); | ||
@@ -170,0 +182,0 @@ }; |
{ | ||
"name": "eh-api-client", | ||
"version": "0.18.0", | ||
"version": "0.19.0", | ||
"description": "Node.js rest client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -53,3 +53,4 @@ var | ||
} | ||
err.code.should.equal("ECONNRESET"); | ||
err.name.should.equal("NetworkError"); | ||
err.message.should.equal("ECONNRESET"); | ||
done(); | ||
@@ -56,0 +57,0 @@ }); |
@@ -91,3 +91,3 @@ var | ||
it("create client with userId = undefined should create guest client", function(done) { | ||
it("create client with userId = undefined should create guest client", function() { | ||
var c = f.getClient(undefined, "web"); | ||
@@ -97,3 +97,3 @@ c.internalAuth.should.equal("0:web"); | ||
it("create client with userId = null should create guest client", function(done) { | ||
it("create client with userId = null should create guest client", function() { | ||
var c = f.getClient(null, "web"); | ||
@@ -100,0 +100,0 @@ c.internalAuth.should.equal("0:web"); |
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 README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
21577
9
743
1
18
4