@autofleet/network 1.2.8 → 1.2.9-alpha-2

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 +9 -6
  2. package/package.json +2 -1
package/index.js CHANGED
@@ -7,6 +7,8 @@ const qs = require('qs');
7
7
  const httpAdapter = require('axios/lib/adapters/http');
8
8
  const merge = require('deepmerge');
9
9
  const { setup } = require('axios-cache-adapter');
10
+ const Agent = require('agentkeepalive');
11
+ const HttpsAgent = require('agentkeepalive').HttpsAgent;
10
12
 
11
13
  require('dotenv').config();
12
14
  /**
@@ -28,7 +30,6 @@ const HTTPMethods = [
28
30
  ];
29
31
 
30
32
  const defaultSettings = {
31
- timeout: 10000,
32
33
  headers: {
33
34
  'X-AF-AUTH': 'ANYONE',
34
35
  'X-IAF-ORIGIN-SERVICE': process.env.AF_SERVICE_NAME || null,
@@ -44,8 +45,10 @@ module.exports = class Network {
44
45
  constructor(settings = {}) {
45
46
  this.settings = merge(defaultSettings, settings);
46
47
  if (this.settings.keepAlive) {
47
- this.settings.httpAgent = new http.Agent({ keepAlive: true});
48
- this.settings.httpsAgent = new https.Agent({ keepAlive: true });
48
+ const keepaliveAgent = new Agent();
49
+ const keepaliveHttpsAgent = new HttpsAgent();
50
+ this.settings.httpAgent = keepaliveAgent;
51
+ this.settings.httpsAgent = keepaliveHttpsAgent;
49
52
  delete this.settings.keepAlive;
50
53
  }
51
54
  this.createBaseUrl();
@@ -61,10 +64,10 @@ module.exports = class Network {
61
64
  }
62
65
  }
63
66
 
64
- this.axios = settings.cache ? setup(this.settings) : axios.create(this.settings);
65
- this.addRetry(settings);
67
+ this.axios = axios.create(this.settings);
68
+ // this.addRetry(settings);
66
69
  this.buildClassHttpMethods();
67
- this.addLogs();
70
+ // this.addLogs();
68
71
  }
69
72
 
70
73
  addRetry(settings) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/network",
3
- "version": "1.2.8",
3
+ "version": "1.2.9-alpha-2",
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",