@evlop/commons 1.0.146 → 1.0.147
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"restApiMiddleware.d.ts","sourceRoot":"","sources":["../../../src/middlewares/restApiMiddleware.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"restApiMiddleware.d.ts","sourceRoot":"","sources":["../../../src/middlewares/restApiMiddleware.tsx"],"names":[],"mappings":"AAgBA,eAAO,MAAM,iBAAiB,yDA4D7B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
@@ -10,7 +10,13 @@ const actions_1 = require("../actions");
|
|
10
10
|
const getUserToken_1 = __importDefault(require("../adapters/getUserToken"));
|
11
11
|
const constants_1 = require("../constants");
|
12
12
|
const lodash_1 = require("lodash");
|
13
|
+
const axios_retry_1 = __importDefault(require("axios-retry"));
|
13
14
|
const apiBaseUrl = constants_1.API_BASE_URL || '/api/';
|
15
|
+
const httpClient = axios_1.default.create();
|
16
|
+
axios_retry_1.default(httpClient, {
|
17
|
+
retries: Number.MAX_SAFE_INTEGER,
|
18
|
+
retryDelay: (retryNumber) => Math.min(5000, axios_retry_1.default.exponentialDelay(retryNumber)),
|
19
|
+
});
|
14
20
|
const restApiMiddleware = (store) => (dispatch) => (action) => {
|
15
21
|
if (action.isRestRequest) {
|
16
22
|
return getUserToken_1.default().then((token) => {
|
@@ -34,33 +40,33 @@ const restApiMiddleware = (store) => (dispatch) => (action) => {
|
|
34
40
|
switch (String(action.method).trim().toUpperCase()) {
|
35
41
|
case actions_1.POST: {
|
36
42
|
dispatch({ type: action.types[0] });
|
37
|
-
return
|
43
|
+
return httpClient.post(endpoint, action.data, lodash_1.defaultsDeep(requestOptions, { params: action.params, headers: action.headers }))
|
38
44
|
.then(resp => (resp.data))
|
39
45
|
.then(response => dispatch(Object.assign(Object.assign({}, action), { success: true, type: action.types[1], response })))
|
40
46
|
.catch(({ response }) => dispatch({ type: action.types[2], error: true, response }));
|
41
47
|
}
|
42
48
|
case actions_1.PUT:
|
43
49
|
dispatch({ type: action.types[0] });
|
44
|
-
return
|
50
|
+
return httpClient.put(endpoint, action.data, lodash_1.defaultsDeep(requestOptions, { params: action.params, headers: action.headers }))
|
45
51
|
.then(resp => (resp.data))
|
46
52
|
.then(response => dispatch(Object.assign(Object.assign({}, action), { success: true, type: action.types[1], response })))
|
47
53
|
.catch(({ response }) => dispatch({ type: action.types[2], error: true, response }));
|
48
54
|
case actions_1.PATCH:
|
49
55
|
dispatch({ type: action.types[0] });
|
50
|
-
return
|
56
|
+
return httpClient.patch(endpoint, action.data, lodash_1.defaultsDeep(requestOptions, { params: action.params, headers: action.headers }))
|
51
57
|
.then(resp => (resp.data))
|
52
58
|
.then(response => dispatch(Object.assign(Object.assign({}, action), { success: true, type: action.types[1], response })))
|
53
59
|
.catch(({ response }) => dispatch({ type: action.types[2], error: true, response }));
|
54
60
|
case actions_1.DELETE:
|
55
61
|
dispatch({ type: action.types[0] });
|
56
|
-
return
|
62
|
+
return httpClient.delete(endpoint, lodash_1.defaultsDeep(requestOptions, { params: action.params, headers: action.headers }))
|
57
63
|
.then(resp => (resp.data))
|
58
64
|
.then(response => dispatch(Object.assign(Object.assign({}, action), { success: true, type: action.types[1], response })))
|
59
65
|
.catch(({ response }) => dispatch({ type: action.types[2], error: true, response }));
|
60
66
|
default:
|
61
67
|
case actions_1.GET:
|
62
68
|
dispatch({ type: action.types[0] });
|
63
|
-
return
|
69
|
+
return httpClient.get(endpoint, lodash_1.defaultsDeep(requestOptions, { params: action.data }, { params: action.params, headers: action.headers }))
|
64
70
|
.then(resp => resp.data)
|
65
71
|
.then(response => dispatch(Object.assign(Object.assign({}, action), { success: true, type: action.types[1], response })))
|
66
72
|
.catch(({ response }) => dispatch({ type: action.types[2], error: true, response }));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"restApiMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/restApiMiddleware.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,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EAAE,EAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAC,CAAC,CAAC;yBACjI,IAAI,CAAC,IAAI,CAAA,EAAE,CAAA,IAAI,CAAC,IAAI,CAAC;yBACrB,IAAI,CAAC,QAAQ,CAAA,EAAE,CAAC,QAAQ,iCAAK,MAAM,KAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,IAAE,CAAC;yBACtF,KAAK,CAAC,CAAC,EAAC,QAAQ,EAAC,EAAC,EAAE,CAAA,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;aACzF;QACL,CAAC,CAAC,CAAC;KACN;;QAEG,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEhC,CAAC,CAAC;AA5DW,QAAA,iBAAiB,qBA4D5B;AAEF,kBAAe,yBAAiB,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@evlop/commons",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.147",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/main.js",
|
6
6
|
"peerDependencies": {
|
@@ -27,6 +27,7 @@
|
|
27
27
|
},
|
28
28
|
"optionalDependencies": {},
|
29
29
|
"dependencies": {
|
30
|
+
"axios-retry": "^3.3.1",
|
30
31
|
"moment": "^2.29.1",
|
31
32
|
"react-native-base64": "^0.2.1"
|
32
33
|
},
|