@alanszp/axios-node 4.0.0 → 4.0.1
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/dist/axios.d.ts +5 -2
- package/dist/axios.js.map +1 -1
- package/package.json +2 -3
- package/src/axios.ts +6 -2
- package/src/errors/Non200ResponseError.ts +1 -1
package/dist/axios.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { RequestSharedContext } from "@alanszp/express";
|
|
3
2
|
import { AsyncLocalStorage } from "async_hooks";
|
|
3
|
+
export interface SharedContext {
|
|
4
|
+
lifecycleId: string;
|
|
5
|
+
lifecycleChain: string;
|
|
6
|
+
}
|
|
4
7
|
export declare const isAxiosError: any;
|
|
5
8
|
export declare function createAxios(): import("axios").AxiosInstance;
|
|
6
|
-
export declare function createAxiosWithTrace(requestSharedContext: AsyncLocalStorage<
|
|
9
|
+
export declare function createAxiosWithTrace(requestSharedContext: AsyncLocalStorage<SharedContext>): import("axios").AxiosInstance;
|
package/dist/axios.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../src/axios.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAgD;
|
|
1
|
+
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../src/axios.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAgD;AAEhD,sEAAmE;AACnE,sEAAmE;AACnE,wDAAqD;AAOxC,QAAA,YAAY,GAAG,eAAW,CAAC,YAAY,CAAC,IAAI,CAAC,eAAW,CAAC,CAAC;AAEvE,SAAS,2BAA2B,CAAI,KAAU;IAChD,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,yCAAmB,CAAI,KAAsB,CAAC,CAAC,CAAC;KAC3E;IAED,IAAI,KAAK,CAAC,OAAO,EAAE;QACjB,OAAO,OAAO,CAAC,M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|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Alan's axios wrapper with base interceptor.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@alanszp/errors": "^4.0.0",
|
|
22
|
-
"@alanszp/express": "^4.0.0",
|
|
23
22
|
"axios": "^0.24.0"
|
|
24
23
|
},
|
|
25
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "f3ba0dcc177ff01f218da91b4505f6b1ca84f0e7"
|
|
26
25
|
}
|
package/src/axios.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import AxiosGlobal, { AxiosError } from "axios";
|
|
2
|
-
import { RequestSharedContext } from "@alanszp/express";
|
|
3
2
|
import { AsyncLocalStorage } from "async_hooks";
|
|
4
3
|
import { NetworkRequestError } from "./errors/NetworkRequestError";
|
|
5
4
|
import { Non200ResponseError } from "./errors/Non200ResponseError";
|
|
6
5
|
import { GenericError } from "./errors/GenericError";
|
|
7
6
|
|
|
7
|
+
export interface SharedContext {
|
|
8
|
+
lifecycleId: string;
|
|
9
|
+
lifecycleChain: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
export const isAxiosError = AxiosGlobal.isAxiosError.bind(AxiosGlobal);
|
|
9
13
|
|
|
10
14
|
function mapAxiosErrorToRequestError<T>(error: any) {
|
|
@@ -31,7 +35,7 @@ export function createAxios() {
|
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
export function createAxiosWithTrace(
|
|
34
|
-
requestSharedContext: AsyncLocalStorage<
|
|
38
|
+
requestSharedContext: AsyncLocalStorage<SharedContext>
|
|
35
39
|
) {
|
|
36
40
|
const axios = AxiosGlobal.create();
|
|
37
41
|
|