@autofleet/network 1.2.8-alpha → 1.2.9-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +6 -7
  2. package/package.json +2 -1
package/index.js CHANGED
@@ -1,8 +1,3 @@
1
- delete process.env['http_proxy'];
2
- delete process.env['HTTP_PROXY'];
3
- delete process.env['https_proxy'];
4
- delete process.env['HTTPS_PROXY'];
5
-
6
1
  const axios = require('axios');
7
2
  const http = require('http');
8
3
  const https = require('https');
@@ -12,6 +7,8 @@ const qs = require('qs');
12
7
  const httpAdapter = require('axios/lib/adapters/http');
13
8
  const merge = require('deepmerge');
14
9
  const { setup } = require('axios-cache-adapter');
10
+ const Agent = require('agentkeepalive');
11
+ const HttpsAgent = require('agentkeepalive').HttpsAgent;
15
12
 
16
13
  require('dotenv').config();
17
14
  /**
@@ -49,8 +46,10 @@ module.exports = class Network {
49
46
  constructor(settings = {}) {
50
47
  this.settings = merge(defaultSettings, settings);
51
48
  if (this.settings.keepAlive) {
52
- this.settings.httpAgent = new http.Agent({ keepAlive: true});
53
- this.settings.httpsAgent = new https.Agent({ keepAlive: true });
49
+ const keepaliveAgent = new Agent();
50
+ const keepaliveHttpsAgent = new HttpsAgent();
51
+ this.settings.httpAgent = keepaliveAgent;
52
+ this.settings.httpsAgent = keepaliveHttpsAgent;
54
53
  delete this.settings.keepAlive;
55
54
  }
56
55
  this.createBaseUrl();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/network",
3
- "version": "1.2.8-alpha",
3
+ "version": "1.2.9-alpha",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -12,6 +12,7 @@
12
12
  "license": "ISC",
13
13
  "dependencies": {
14
14
  "@autofleet/node-common": "^1.5.1",
15
+ "agentkeepalive": "^4.1.4",
15
16
  "axios": "^0.21.1",
16
17
  "axios-cache-adapter": "^2.7.3",
17
18
  "axios-retry": "^3.1.1",