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,
|
HttpModuleOptionsFactory,
|
||||||
} from './interfaces';
|
} from './interfaces';
|
||||||
import axiosRetry from 'axios-retry';
|
import axiosRetry from 'axios-retry';
|
||||||
|
import axiosBetterStacktrace from 'axios-better-stacktrace';
|
||||||
|
|
||||||
const createAxiosRetry = (config: HttpModuleOptions) => {
|
const createAxiosInstance = (config: HttpModuleOptions) => {
|
||||||
const axiosInstance = Axios.create(config);
|
const axiosInstance = Axios.create(config);
|
||||||
axiosRetry(axiosInstance, config);
|
axiosRetry(axiosInstance, config);
|
||||||
|
axiosBetterStacktrace(axiosInstance);
|
||||||
return axiosInstance;
|
return axiosInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +39,7 @@ export class HttpModule {
|
||||||
providers: [
|
providers: [
|
||||||
{
|
{
|
||||||
provide: AXIOS_INSTANCE_TOKEN,
|
provide: AXIOS_INSTANCE_TOKEN,
|
||||||
useValue: createAxiosRetry(config),
|
useValue: createAxiosInstance(config),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: HTTP_MODULE_ID,
|
provide: HTTP_MODULE_ID,
|
||||||
|
@ -55,7 +57,7 @@ export class HttpModule {
|
||||||
...this.createAsyncProviders(options),
|
...this.createAsyncProviders(options),
|
||||||
{
|
{
|
||||||
provide: AXIOS_INSTANCE_TOKEN,
|
provide: AXIOS_INSTANCE_TOKEN,
|
||||||
useFactory: (config: HttpModuleOptions) => createAxiosRetry(config),
|
useFactory: (config: HttpModuleOptions) => createAxiosInstance(config),
|
||||||
inject: [HTTP_MODULE_OPTIONS],
|
inject: [HTTP_MODULE_OPTIONS],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
10
package-lock.json
generated
10
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "nestjs-http-promise",
|
"name": "nestjs-http-promise",
|
||||||
"version": "1.0.1",
|
"version": "1.1.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -486,7 +486,8 @@
|
||||||
"ansi-regex": {
|
"ansi-regex": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
"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": {
|
"ansi-styles": {
|
||||||
"version": "4.3.0",
|
"version": "4.3.0",
|
||||||
|
@ -562,6 +563,11 @@
|
||||||
"follow-redirects": "^1.14.4"
|
"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": {
|
"axios-retry": {
|
||||||
"version": "3.2.4",
|
"version": "3.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-3.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-3.2.4.tgz",
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "~0.24.0",
|
"axios": "~0.24.0",
|
||||||
|
"axios-better-stacktrace": "^2.1.2",
|
||||||
"axios-retry": "^3.2.4"
|
"axios-retry": "^3.2.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
Loading…
Reference in a new issue