Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eh-api-client

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eh-api-client - npm Package Compare versions

Comparing version 0.10.0 to 0.12.0

test/keep_alive.js

43

index.js
var
request = require("request"),
request = require("requestretry"),
Q = require("q"),
_ = require("lodash");
_ = require("lodash"),
Agent = require("http").Agent;

@@ -52,2 +53,3 @@ function buildError(res, data, url, method) {

this.apiURL = apiURL;
this._factory = null;
};

@@ -58,2 +60,3 @@

var newClient = new Client(apiURL, this._options);
newClient._factory = this._factory;
return newClient;

@@ -167,4 +170,6 @@ };

Client.prototype._makeRequest = function() {
return request.apply(this, arguments);
Client.prototype._makeRequest = function(params, cb) {
params.agent = this._factory.agent;
_.extend(params, this._factory.retryOptions);
return request(params, cb);
};

@@ -208,2 +213,11 @@

this.apiURL = apiURL;
this.retryOptions = {
maxAttempts: 5,
retryDelay: 100,
retryStrategy: request.RetryStrategies.NetworkError
};
this.agent = new Agent({
keepAlive: true,
maxSockets: 1000
});
};

@@ -213,2 +227,17 @@

Factory.prototype.setRetryOptions = function(options) {
var self = this;
var allowOpts = ["maxAttempts", "retryDelay", "retryStrategy"];
allowOpts.forEach(function(k) {
if(k in options) {
self.retryOptions[k] = options[k];
}
});
};
Factory.prototype.setAgentOptions = function(options) {
_.defaults(options, {keepAlive: true});
self.agent = new Agent(options);
};
Factory.prototype.exists = function() {

@@ -224,2 +253,3 @@ var c = new Client(this.apiURL);

var c = new Client(this.apiURL);
c._factory = this;
return c.request.apply(c, args);

@@ -254,2 +284,3 @@ };

});
client._factory = self;
cb(null, client);

@@ -264,7 +295,9 @@ });

Factory.prototype.getClient = function(userId, app) {
return new Client(this.apiURL, {
var client = new Client(this.apiURL, {
internalAuth: userId + ":" + app
});
client._factory = this;
return client;
};
module.exports = Factory;

5

package.json
{
"name": "eh-api-client",
"version": "0.10.0",
"version": "0.12.0",
"description": "Node.js rest client",

@@ -18,5 +18,6 @@ "main": "index.js",

"q": "^1.4.1",
"request": "^2.55.0"
"requestretry": "^1.4.0"
},
"devDependencies": {
"async": "^1.4.0",
"eh-guid": "^0.2.0",

@@ -23,0 +24,0 @@ "should": "^6.0.3",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc