@metarisc/metarisc-js 0.0.1-alpha.2 → 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/.github/workflows/main.yml +29 -0
- package/lib/metarisc.d.ts +1 -1
- package/lib/metarisc.js +8 -1
- package/package.json +3 -2
- package/src/metarisc.ts +7 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: "CI"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
|
|
9
|
+
build:
|
|
10
|
+
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
|
|
15
|
+
- uses: actions/checkout@v3
|
|
16
|
+
|
|
17
|
+
- uses: actions/setup-node@v3
|
|
18
|
+
with:
|
|
19
|
+
registry-url: 'https://registry.npmjs.org'
|
|
20
|
+
|
|
21
|
+
- run: npm install
|
|
22
|
+
|
|
23
|
+
- run: npm run compile
|
|
24
|
+
|
|
25
|
+
- run: npm run lint
|
|
26
|
+
|
|
27
|
+
- run: npm publish --access=public
|
|
28
|
+
env:
|
|
29
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/lib/metarisc.d.ts
CHANGED
package/lib/metarisc.js
CHANGED
|
@@ -2,18 +2,25 @@
|
|
|
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({
|
|
13
19
|
method: config.method || 'GET',
|
|
14
20
|
url: config.endpoint || '/',
|
|
15
21
|
params: config.params,
|
|
16
|
-
data: config.body
|
|
22
|
+
data: config.body,
|
|
23
|
+
headers: config.headers
|
|
17
24
|
});
|
|
18
25
|
}
|
|
19
26
|
async *autoPagingIterator(config) {
|
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.
|
|
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>>
|