@metarisc/metarisc-js 0.0.1-alpha.3 → 0.0.1-alpha.4

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.
package/lib/metarisc.js CHANGED
@@ -2,11 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Metarisc = void 0;
4
4
  const axios_1 = require("axios");
5
+ const axios_retry_1 = require("axios-retry");
5
6
  class Metarisc {
6
7
  constructor() {
7
8
  this.axios = axios_1.default.create({
8
9
  baseURL: 'https://api.metarisc.fr/'
9
10
  });
11
+ // Axios interceptor : Retry strategy
12
+ (0, axios_retry_1.default)(this.axios, {
13
+ retries: 3,
14
+ retryDelay: axios_retry_1.default.exponentialDelay
15
+ });
10
16
  }
11
17
  async request(config) {
12
18
  return this.axios.request({
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@metarisc/metarisc-js",
3
3
  "main": "lib/index.js",
4
4
  "types": "lib/index.d.ts",
5
- "version": "0.0.1-alpha.3",
5
+ "version": "0.0.1-alpha.4",
6
6
  "scripts": {
7
7
  "lint": "eslint . --ext .ts",
8
8
  "compile": "tsc"
@@ -15,6 +15,7 @@
15
15
  "typescript": "^4.9.5"
16
16
  },
17
17
  "dependencies": {
18
- "axios": "^1.4.0"
18
+ "axios": "^1.4.0",
19
+ "axios-retry": "^3.5.0"
19
20
  }
20
21
  }
package/src/metarisc.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import axios, { AxiosInstance, AxiosResponse } from "axios";
2
+ import axiosRetry from 'axios-retry';
2
3
 
3
4
  interface RequestConfig {
4
5
  body ?: any,
@@ -17,6 +18,12 @@ export class Metarisc
17
18
  this.axios = axios.create({
18
19
  baseURL: 'https://api.metarisc.fr/'
19
20
  });
21
+
22
+ // Axios interceptor : Retry strategy
23
+ axiosRetry(this.axios, {
24
+ retries: 3,
25
+ retryDelay: axiosRetry.exponentialDelay
26
+ });
20
27
  }
21
28
 
22
29
  async request<T>(config : RequestConfig) : Promise<AxiosResponse<T>>