@hg-ts/http-controller 0.2.5 → 0.2.7
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception-mapper.interceptor.d.ts","sourceRoot":"","sources":["../../src/middlewares/exception-mapper.interceptor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,EACN,WAAW,EAEX,gBAAgB,EAEhB,eAAe,EACf,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"exception-mapper.interceptor.d.ts","sourceRoot":"","sources":["../../src/middlewares/exception-mapper.interceptor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,EACN,WAAW,EAEX,gBAAgB,EAEhB,eAAe,EACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACN,UAAU,EAEV,MAAM,MAAM,CAAC;AAMd,qBACa,0BAA2B,YAAW,eAAe;IAEjE,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAE3B,SAAS,CACf,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,GACf,UAAU,CAAC,GAAG,CAAC;IAoBlB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,YAAY;CAWpB"}
|
|
@@ -6,6 +6,7 @@ const exception_1 = require("@hg-ts/exception");
|
|
|
6
6
|
const logger_1 = require("@hg-ts/logger");
|
|
7
7
|
const validation_1 = require("@hg-ts/validation");
|
|
8
8
|
const common_1 = require("@nestjs/common");
|
|
9
|
+
const axios_1 = require("axios");
|
|
9
10
|
const rxjs_1 = require("rxjs");
|
|
10
11
|
const decorators_1 = require("../decorators");
|
|
11
12
|
let ExceptionMapperInterceptor = class ExceptionMapperInterceptor {
|
|
@@ -13,10 +14,14 @@ let ExceptionMapperInterceptor = class ExceptionMapperInterceptor {
|
|
|
13
14
|
intercept(context, next) {
|
|
14
15
|
return next.handle().pipe((0, rxjs_1.tap)({
|
|
15
16
|
error: error => {
|
|
17
|
+
const response = context.switchToHttp().getResponse();
|
|
18
|
+
if ((0, axios_1.isAxiosError)(error)) {
|
|
19
|
+
response.status(error.status ?? 500).send(error.response?.data);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
16
22
|
const exception = this.getException(error);
|
|
17
23
|
const exceptionMap = this.getExceptionMap(context);
|
|
18
24
|
const exceptionCtor = this.getExceptionCtor(exception);
|
|
19
|
-
const response = context.switchToHttp().getResponse();
|
|
20
25
|
const status = exceptionMap.get(exceptionCtor);
|
|
21
26
|
response.status(status ?? 500).send(exception.toJSON());
|
|
22
27
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception-mapper.interceptor.js","sourceRoot":"","sources":["../../src/middlewares/exception-mapper.interceptor.ts"],"names":[],"mappings":";;;;AAAA,gDAG0B;AAC1B,0CAAuC;AACvC,kDAAwD;AAExD,2CAMwB;
|
|
1
|
+
{"version":3,"file":"exception-mapper.interceptor.js","sourceRoot":"","sources":["../../src/middlewares/exception-mapper.interceptor.ts"],"names":[],"mappings":";;;;AAAA,gDAG0B;AAC1B,0CAAuC;AACvC,kDAAwD;AAExD,2CAMwB;AACxB,iCAAqC;AAErC,+BAGc;AACd,8CAGuB;AAGhB,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAEnB,MAAM,CAAS;IAE3B,SAAS,CACf,OAAyB,EACzB,IAAiB;QAEjB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAA,UAAG,EAAC;YAC7B,KAAK,EAAE,KAAK,CAAC,EAAE;gBACd,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,WAAW,EAAgB,CAAC;gBAEpE,IAAI,IAAA,oBAAY,EAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,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AAI,0BAAc,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,IAAI,0BAAc,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;CACD,CAAA;AAxDY,gEAA0B;AAEnB;IADlB,IAAA,eAAM,GAAE;sCACkB,eAAM;0DAAC;qCAFtB,0BAA0B;IADtC,IAAA,cAAK,GAAE;GACK,0BAA0B,CAwDtC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hg-ts/http-controller",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js"
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"test:dev": "yarn build:dev --onSuccess \"yarn test\""
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@hg-ts-config/typescript": "0.2.
|
|
21
|
-
"@hg-ts/exception": "0.2.
|
|
22
|
-
"@hg-ts/execution-mode": "0.2.
|
|
23
|
-
"@hg-ts/knex": "0.2.
|
|
24
|
-
"@hg-ts/linter": "0.2.
|
|
25
|
-
"@hg-ts/logger": "0.2.
|
|
26
|
-
"@hg-ts/tests": "0.2.
|
|
27
|
-
"@hg-ts/types": "0.2.
|
|
28
|
-
"@hg-ts/validation": "0.2.
|
|
20
|
+
"@hg-ts-config/typescript": "0.2.7",
|
|
21
|
+
"@hg-ts/exception": "0.2.7",
|
|
22
|
+
"@hg-ts/execution-mode": "0.2.7",
|
|
23
|
+
"@hg-ts/knex": "0.2.7",
|
|
24
|
+
"@hg-ts/linter": "0.2.7",
|
|
25
|
+
"@hg-ts/logger": "0.2.7",
|
|
26
|
+
"@hg-ts/tests": "0.2.7",
|
|
27
|
+
"@hg-ts/types": "0.2.7",
|
|
28
|
+
"@hg-ts/validation": "0.2.7",
|
|
29
29
|
"@nestjs/common": "11.1.0",
|
|
30
30
|
"@nestjs/core": "11.1.0",
|
|
31
31
|
"@nestjs/platform-fastify": "11.1.0",
|
|
@@ -44,15 +44,16 @@
|
|
|
44
44
|
"typescript": "5.7.3"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@hg-ts/exception": "0.2.
|
|
48
|
-
"@hg-ts/execution-mode": "0.2.
|
|
49
|
-
"@hg-ts/knex": "0.2.
|
|
50
|
-
"@hg-ts/logger": "0.2.
|
|
51
|
-
"@hg-ts/validation": "0.2.
|
|
47
|
+
"@hg-ts/exception": "0.2.7",
|
|
48
|
+
"@hg-ts/execution-mode": "0.2.7",
|
|
49
|
+
"@hg-ts/knex": "0.2.7",
|
|
50
|
+
"@hg-ts/logger": "0.2.7",
|
|
51
|
+
"@hg-ts/validation": "0.2.7",
|
|
52
52
|
"@nestjs/common": "*",
|
|
53
53
|
"@nestjs/core": "*",
|
|
54
54
|
"@nestjs/platform-fastify": "*",
|
|
55
55
|
"@nestjs/swagger": "*",
|
|
56
|
+
"axios": "*",
|
|
56
57
|
"reflect-metadata": "*",
|
|
57
58
|
"rxjs": "*",
|
|
58
59
|
"tslib": "*"
|