@autofleet/network 1.1.1 → 1.1.3

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 +10 -0
  2. package/package.json +4 -3
package/index.js CHANGED
@@ -4,6 +4,8 @@ const { Logger } = require('@autofleet/node-common');
4
4
  const qs = require('qs');
5
5
  const httpAdapter = require('axios/lib/adapters/http');
6
6
  const merge = require('deepmerge');
7
+ const { setupCache } = require('axios-cache-adapter');
8
+
7
9
  require('dotenv').config();
8
10
  /**
9
11
  * Add support for nock testing
@@ -37,6 +39,14 @@ module.exports = class Network {
37
39
  this.settings = merge(defaultSettings, settings);
38
40
  this.createBaseUrl();
39
41
 
42
+ if(settings.cache) {
43
+ const cache = setupCache({
44
+ maxAge: 15 * 60 * 1000,
45
+ ...settings.cache
46
+ });
47
+ settings.adapter = cache.adapter;
48
+ }
49
+
40
50
  this.axios = axios.create(this.settings);
41
51
  this.addRetry(settings);
42
52
  this.buildClassHttpMethods();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/network",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,8 +11,9 @@
11
11
  "author": "Dor Shay",
12
12
  "license": "ISC",
13
13
  "dependencies": {
14
- "@autofleet/node-common": "^1.1.50",
15
- "axios": "^0.18.0",
14
+ "@autofleet/node-common": "^1.5.1",
15
+ "axios": "^0.19.2",
16
+ "axios-cache-adapter": "^2.5.0",
16
17
  "axios-retry": "^3.1.1",
17
18
  "deepmerge": "^3.0.0",
18
19
  "dotenv": "^6.0.0",