From 8c9ac53b06de6441f79b9020b680cbcf36a409c6 Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 23 Dec 2021 20:09:52 +0200 Subject: [PATCH] added better error stack trace --- lib/http.module.ts | 8 +++++--- package-lock.json | 10 ++++++++-- package.json | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/http.module.ts b/lib/http.module.ts index 065d4b7..a26a86b 100644 --- a/lib/http.module.ts +++ b/lib/http.module.ts @@ -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], }, { diff --git a/package-lock.json b/package-lock.json index 13792fd..008d0cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 925c662..61ef73d 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ }, "dependencies": { "axios": "~0.24.0", + "axios-better-stacktrace": "^2.1.2", "axios-retry": "^3.2.4" }, "devDependencies": {