added better error stack trace
This commit is contained in:
parent
995e61e8a7
commit
8c9ac53b06
3 changed files with 14 additions and 5 deletions
|
@ -13,10 +13,12 @@ import {
|
|||
HttpModuleOptionsFactory,
|
||||
} from './interfaces';
|
||||
import axiosRetry from 'axios-retry';
|
||||
import axiosBetterStacktrace from 'axios-better-stacktrace';
|
||||
|
||||
const createAxiosRetry = (config: HttpModuleOptions) => {
|
||||
const createAxiosInstance = (config: HttpModuleOptions) => {
|
||||
const axiosInstance = Axios.create(config);
|
||||
axiosRetry(axiosInstance, config);
|
||||
axiosBetterStacktrace(axiosInstance);
|
||||
return axiosInstance;
|
||||
}
|
||||
|
||||
|
@ -37,7 +39,7 @@ export class HttpModule {
|
|||
providers: [
|
||||
{
|
||||
provide: AXIOS_INSTANCE_TOKEN,
|
||||
useValue: createAxiosRetry(config),
|
||||
useValue: createAxiosInstance(config),
|
||||
},
|
||||
{
|
||||
provide: HTTP_MODULE_ID,
|
||||
|
@ -55,7 +57,7 @@ export class HttpModule {
|
|||
...this.createAsyncProviders(options),
|
||||
{
|
||||
provide: AXIOS_INSTANCE_TOKEN,
|
||||
useFactory: (config: HttpModuleOptions) => createAxiosRetry(config),
|
||||
useFactory: (config: HttpModuleOptions) => createAxiosInstance(config),
|
||||
inject: [HTTP_MODULE_OPTIONS],
|
||||
},
|
||||
{
|
||||
|
|
10
package-lock.json
generated
10
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "nestjs-http-promise",
|
||||
"version": "1.0.1",
|
||||
"version": "1.1.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -486,7 +486,8 @@
|
|||
"ansi-regex": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="
|
||||
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||
"dev": true
|
||||
},
|
||||
"ansi-styles": {
|
||||
"version": "4.3.0",
|
||||
|
@ -562,6 +563,11 @@
|
|||
"follow-redirects": "^1.14.4"
|
||||
}
|
||||
},
|
||||
"axios-better-stacktrace": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/axios-better-stacktrace/-/axios-better-stacktrace-2.1.2.tgz",
|
||||
"integrity": "sha512-/ikpK5W7UhCAdl9pQss1vpTfLtOQpbv8edRZ2a9wWSux2dnGmqjVHkFsMKnyllysxm046C016lqGjUgGNECcag=="
|
||||
},
|
||||
"axios-retry": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-3.2.4.tgz",
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"axios": "~0.24.0",
|
||||
"axios-better-stacktrace": "^2.1.2",
|
||||
"axios-retry": "^3.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Loading…
Reference in a new issue