eh-api-client
Advanced tools
Comparing version 0.24.4 to 0.25.0
13
index.js
@@ -28,2 +28,11 @@ var | ||
this.Client = getClientClass(); | ||
this._client; | ||
this.__defineGetter__("client", function() { | ||
if(!this._client) { | ||
this._client = new this.Client(this.apiURL); | ||
this._client._factory = this; | ||
} | ||
return this._client; | ||
}); | ||
}; | ||
@@ -60,5 +69,3 @@ | ||
args.unshift(method); | ||
var c = new this.Client(this.apiURL); | ||
c._factory = this; | ||
return c.request.apply(c, args); | ||
return this.client.request.apply(this.client, args); | ||
}; | ||
@@ -65,0 +72,0 @@ }); |
@@ -60,4 +60,18 @@ var | ||
this._factory = null; | ||
this._requestModificators = []; | ||
}; | ||
Client.prototype.addRequestModificator = function(func) { | ||
if(this._requestModificators.indexOf(func) === -1) { | ||
this._requestModificators.push(func); | ||
} | ||
}; | ||
Client.prototype.removeRequestModificator = function(func) { | ||
var index = this._requestModificators.indexOf(func); | ||
if(index >= 0) { | ||
this._requestModificators.splice(index, 1); | ||
} | ||
}; | ||
Client.prototype.fork = function(subUrl) { | ||
@@ -213,5 +227,10 @@ apiURL = this.apiURL + _url(subUrl); | ||
Client.prototype._makeRequest = function(params, cb) { | ||
var self = this; | ||
params.agent = this._factory.agent; | ||
_.extend(params, this._factory.requestOptions); | ||
return this._tryRequest(params, 1, cb); | ||
return Promise.each(this._requestModificators, function(modificator) { | ||
return modificator(params); | ||
}).then(function() { | ||
return self._tryRequest(params, 1, cb); | ||
}); | ||
}; | ||
@@ -218,0 +237,0 @@ |
{ | ||
"name": "eh-api-client", | ||
"version": "0.24.4", | ||
"version": "0.25.0", | ||
"description": "Node.js rest client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
72364
12
1666
5