@tsed/platform-exceptions 6.87.2 → 6.90.0
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/lib/{components → cjs/components}/ErrorFilter.d.ts +0 -0
- package/lib/cjs/components/ErrorFilter.js +48 -0
- package/lib/cjs/components/ErrorFilter.js.map +1 -0
- package/lib/{components → cjs/components}/ExceptionFilter.d.ts +0 -0
- package/lib/cjs/components/ExceptionFilter.js +23 -0
- package/lib/cjs/components/ExceptionFilter.js.map +1 -0
- package/lib/{components → cjs/components}/MongooseErrorFilter.d.ts +0 -0
- package/lib/cjs/components/MongooseErrorFilter.js +17 -0
- package/lib/cjs/components/MongooseErrorFilter.js.map +1 -0
- package/lib/{components → cjs/components}/StringErrorFilter.d.ts +0 -0
- package/lib/cjs/components/StringErrorFilter.js +16 -0
- package/lib/cjs/components/StringErrorFilter.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/catch.d.ts +0 -0
- package/lib/cjs/decorators/catch.js +23 -0
- package/lib/cjs/decorators/catch.js.map +1 -0
- package/lib/{domain → cjs/domain}/ExceptionFiltersContainer.d.ts +0 -0
- package/lib/cjs/domain/ExceptionFiltersContainer.js +16 -0
- package/lib/cjs/domain/ExceptionFiltersContainer.js.map +1 -0
- package/lib/{domain → cjs/domain}/ExceptionSchema.d.ts +0 -0
- package/lib/cjs/domain/ExceptionSchema.js +36 -0
- package/lib/cjs/domain/ExceptionSchema.js.map +1 -0
- package/lib/{errors → cjs/errors}/ResourceNotFound.d.ts +0 -0
- package/lib/cjs/errors/ResourceNotFound.js +12 -0
- package/lib/cjs/errors/ResourceNotFound.js.map +1 -0
- package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
- package/lib/cjs/index.js +19 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/ExceptionFilterMethods.d.ts +0 -0
- package/lib/cjs/interfaces/ExceptionFilterMethods.js +3 -0
- package/lib/cjs/interfaces/ExceptionFilterMethods.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformExceptions.d.ts +0 -0
- package/lib/cjs/services/PlatformExceptions.js +55 -0
- package/lib/cjs/services/PlatformExceptions.js.map +1 -0
- package/lib/esm/components/ErrorFilter.js +45 -0
- package/lib/esm/components/ErrorFilter.js.map +1 -0
- package/lib/esm/components/ExceptionFilter.js +20 -0
- package/lib/esm/components/ExceptionFilter.js.map +1 -0
- package/lib/esm/components/MongooseErrorFilter.js +14 -0
- package/lib/esm/components/MongooseErrorFilter.js.map +1 -0
- package/lib/esm/components/StringErrorFilter.js +13 -0
- package/lib/esm/components/StringErrorFilter.js.map +1 -0
- package/lib/esm/decorators/catch.js +19 -0
- package/lib/esm/decorators/catch.js.map +1 -0
- package/lib/esm/domain/ExceptionFiltersContainer.js +12 -0
- package/lib/esm/domain/ExceptionFiltersContainer.js.map +1 -0
- package/lib/esm/domain/ExceptionSchema.js +33 -0
- package/lib/esm/domain/ExceptionSchema.js.map +1 -0
- package/lib/esm/errors/ResourceNotFound.js +8 -0
- package/lib/esm/errors/ResourceNotFound.js.map +1 -0
- package/lib/esm/index.js +16 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/ExceptionFilterMethods.js +2 -0
- package/lib/esm/interfaces/ExceptionFilterMethods.js.map +1 -0
- package/lib/esm/services/PlatformExceptions.js +52 -0
- package/lib/esm/services/PlatformExceptions.js.map +1 -0
- package/lib/types/components/ErrorFilter.d.ts +15 -0
- package/lib/types/components/ExceptionFilter.d.ts +6 -0
- package/lib/types/components/MongooseErrorFilter.d.ts +5 -0
- package/lib/types/components/StringErrorFilter.d.ts +5 -0
- package/lib/types/decorators/catch.d.ts +7 -0
- package/lib/types/domain/ExceptionFiltersContainer.d.ts +14 -0
- package/lib/types/domain/ExceptionSchema.d.ts +1 -0
- package/lib/types/errors/ResourceNotFound.d.ts +5 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/interfaces/ExceptionFilterMethods.d.ts +4 -0
- package/lib/types/services/PlatformExceptions.d.ts +15 -0
- package/package.json +18 -14
- package/tsconfig.compile.esm.json +23 -0
- package/lib/index.js +0 -248
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -224
- package/lib/index.modern.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AAEjD,aAAa;AACb,cAAc,oBAAoB,CAAC;AAEnC,SAAS;AACT,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,qCAAqC,CAAC;AAEpD,cAAc;AACd,cAAc,+BAA+B,CAAC;AAE9C,SAAS;AACT,cAAc,2BAA2B,CAAC","sourcesContent":["// components\nexport * from \"./components/StringErrorFilter\";\nexport * from \"./components/ExceptionFilter\";\nexport * from \"./components/ErrorFilter\";\nexport * from \"./components/MongooseErrorFilter\";\n\n// decorators\nexport * from \"./decorators/catch\";\n\n// domain\nexport * from \"./domain/ExceptionFiltersContainer\";\nexport * from \"./domain/ExceptionSchema\";\nexport * from \"./interfaces/ExceptionFilterMethods\";\n\n// middlewares\nexport * from \"./services/PlatformExceptions\";\n\n// errors\nexport * from \"./errors/ResourceNotFound\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExceptionFilterMethods.js","sourceRoot":"","sources":["../../../src/interfaces/ExceptionFilterMethods.ts"],"names":[],"mappings":"","sourcesContent":["import {BaseContext} from \"@tsed/di\";\n\nexport interface ExceptionFilterMethods<T = unknown> {\n catch(error: T, ctx: BaseContext): void;\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { ancestorsOf, classOf, nameOf } from "@tsed/core";
|
|
3
|
+
import { Inject, Injectable, InjectorService } from "@tsed/di";
|
|
4
|
+
import { ErrorFilter } from "../components/ErrorFilter";
|
|
5
|
+
import { ExceptionFilter } from "../components/ExceptionFilter";
|
|
6
|
+
import { MongooseErrorFilter } from "../components/MongooseErrorFilter";
|
|
7
|
+
import { StringErrorFilter } from "../components/StringErrorFilter";
|
|
8
|
+
import { ExceptionFiltersContainer } from "../domain/ExceptionFiltersContainer";
|
|
9
|
+
import { ResourceNotFound } from "../errors/ResourceNotFound";
|
|
10
|
+
/**
|
|
11
|
+
* Catch all errors and return the json error with the right status code when it's possible.
|
|
12
|
+
*
|
|
13
|
+
* @platform
|
|
14
|
+
*/
|
|
15
|
+
let PlatformExceptions = class PlatformExceptions {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.types = new Map();
|
|
18
|
+
}
|
|
19
|
+
$onInit() {
|
|
20
|
+
ExceptionFiltersContainer.forEach((token, type) => {
|
|
21
|
+
this.types.set(type, this.injector.get(token));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
catch(error, ctx) {
|
|
25
|
+
const name = nameOf(classOf(error));
|
|
26
|
+
if (name && this.types.has(name)) {
|
|
27
|
+
return this.types.get(name).catch(error, ctx);
|
|
28
|
+
}
|
|
29
|
+
const target = ancestorsOf(error)
|
|
30
|
+
.reverse()
|
|
31
|
+
.find((target) => this.types.has(target));
|
|
32
|
+
if (target) {
|
|
33
|
+
return this.types.get(target).catch(error, ctx);
|
|
34
|
+
}
|
|
35
|
+
// default
|
|
36
|
+
return this.types.get(Error).catch(error, ctx);
|
|
37
|
+
}
|
|
38
|
+
resourceNotFound(ctx) {
|
|
39
|
+
return this.catch(new ResourceNotFound(ctx.request.url), ctx);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
__decorate([
|
|
43
|
+
Inject(),
|
|
44
|
+
__metadata("design:type", InjectorService)
|
|
45
|
+
], PlatformExceptions.prototype, "injector", void 0);
|
|
46
|
+
PlatformExceptions = __decorate([
|
|
47
|
+
Injectable({
|
|
48
|
+
imports: [ErrorFilter, ExceptionFilter, MongooseErrorFilter, StringErrorFilter]
|
|
49
|
+
})
|
|
50
|
+
], PlatformExceptions);
|
|
51
|
+
export { PlatformExceptions };
|
|
52
|
+
//# sourceMappingURL=PlatformExceptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformExceptions.js","sourceRoot":"","sources":["../../../src/services/PlatformExceptions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AACxD,OAAO,EAAc,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAC,mBAAmB,EAAC,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAC,iBAAiB,EAAC,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAqB,yBAAyB,EAAC,MAAM,qCAAqC,CAAC;AAClG,OAAO,EAAC,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AAG5D;;;;GAIG;AAIH,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAA/B;QACE,UAAK,GAAoD,IAAI,GAAG,EAAE,CAAC;IAiCrE,CAAC;IA5BC,OAAO;QACL,yBAAyB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAChD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAc,EAAE,GAAgB;QACpC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAEpC,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAChC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SAChD;QAED,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC;aAC9B,OAAO,EAAE;aACT,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QAE5C,IAAI,MAAM,EAAE;YACV,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SAClD;QAED,UAAU;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;IAED,gBAAgB,CAAC,GAAgB;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;CACF,CAAA;AA9BC;IADC,MAAM,EAAE;8BACC,eAAe;oDAAC;AAJf,kBAAkB;IAH9B,UAAU,CAAC;QACV,OAAO,EAAE,CAAC,WAAW,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,CAAC;KAChF,CAAC;GACW,kBAAkB,CAkC9B;SAlCY,kBAAkB","sourcesContent":["import {ancestorsOf, classOf, nameOf} from \"@tsed/core\";\nimport {BaseContext, Inject, Injectable, InjectorService} from \"@tsed/di\";\nimport {ErrorFilter} from \"../components/ErrorFilter\";\nimport {ExceptionFilter} from \"../components/ExceptionFilter\";\nimport {MongooseErrorFilter} from \"../components/MongooseErrorFilter\";\nimport {StringErrorFilter} from \"../components/StringErrorFilter\";\nimport {ExceptionFilterKey, ExceptionFiltersContainer} from \"../domain/ExceptionFiltersContainer\";\nimport {ResourceNotFound} from \"../errors/ResourceNotFound\";\nimport {ExceptionFilterMethods} from \"../interfaces/ExceptionFilterMethods\";\n\n/**\n * Catch all errors and return the json error with the right status code when it's possible.\n *\n * @platform\n */\n@Injectable({\n imports: [ErrorFilter, ExceptionFilter, MongooseErrorFilter, StringErrorFilter]\n})\nexport class PlatformExceptions {\n types: Map<ExceptionFilterKey, ExceptionFilterMethods> = new Map();\n\n @Inject()\n injector: InjectorService;\n\n $onInit() {\n ExceptionFiltersContainer.forEach((token, type) => {\n this.types.set(type, this.injector.get(token)!);\n });\n }\n\n catch(error: unknown, ctx: BaseContext) {\n const name = nameOf(classOf(error));\n\n if (name && this.types.has(name)) {\n return this.types.get(name)!.catch(error, ctx);\n }\n\n const target = ancestorsOf(error)\n .reverse()\n .find((target) => this.types.has(target));\n\n if (target) {\n return this.types.get(target)!.catch(error, ctx);\n }\n\n // default\n return this.types.get(Error)!.catch(error, ctx);\n }\n\n resourceNotFound(ctx: BaseContext) {\n return this.catch(new ResourceNotFound(ctx.request.url), ctx);\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Env } from "@tsed/core";
|
|
2
|
+
import { BaseContext } from "@tsed/di";
|
|
3
|
+
import type { ExceptionFilterMethods } from "../interfaces/ExceptionFilterMethods";
|
|
4
|
+
export declare class ErrorFilter implements ExceptionFilterMethods {
|
|
5
|
+
catch(error: any, ctx: BaseContext): void;
|
|
6
|
+
mapError(error: any, env?: Env): {
|
|
7
|
+
name: any;
|
|
8
|
+
message: any;
|
|
9
|
+
status: any;
|
|
10
|
+
errors: any;
|
|
11
|
+
stack: any;
|
|
12
|
+
};
|
|
13
|
+
protected getErrors(error: any): any;
|
|
14
|
+
protected getHeaders(error: any): any;
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import type { ExceptionFilterMethods } from "../interfaces/ExceptionFilterMethods";
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export declare type ExceptionFilterKey = Type<any> | Symbol | string;
|
|
7
|
+
/**
|
|
8
|
+
* @ignore
|
|
9
|
+
*/
|
|
10
|
+
export declare const ExceptionFiltersContainer: Map<ExceptionFilterKey, Type<ExceptionFilterMethods<unknown>>>;
|
|
11
|
+
/**
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
export declare function registerExceptionType(type: ExceptionFilterKey, token: Type<ExceptionFilterMethods>): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./components/StringErrorFilter";
|
|
2
|
+
export * from "./components/ExceptionFilter";
|
|
3
|
+
export * from "./components/ErrorFilter";
|
|
4
|
+
export * from "./components/MongooseErrorFilter";
|
|
5
|
+
export * from "./decorators/catch";
|
|
6
|
+
export * from "./domain/ExceptionFiltersContainer";
|
|
7
|
+
export * from "./domain/ExceptionSchema";
|
|
8
|
+
export * from "./interfaces/ExceptionFilterMethods";
|
|
9
|
+
export * from "./services/PlatformExceptions";
|
|
10
|
+
export * from "./errors/ResourceNotFound";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseContext, InjectorService } from "@tsed/di";
|
|
2
|
+
import { ExceptionFilterKey } from "../domain/ExceptionFiltersContainer";
|
|
3
|
+
import { ExceptionFilterMethods } from "../interfaces/ExceptionFilterMethods";
|
|
4
|
+
/**
|
|
5
|
+
* Catch all errors and return the json error with the right status code when it's possible.
|
|
6
|
+
*
|
|
7
|
+
* @platform
|
|
8
|
+
*/
|
|
9
|
+
export declare class PlatformExceptions {
|
|
10
|
+
types: Map<ExceptionFilterKey, ExceptionFilterMethods>;
|
|
11
|
+
injector: InjectorService;
|
|
12
|
+
$onInit(): void;
|
|
13
|
+
catch(error: unknown, ctx: BaseContext): void;
|
|
14
|
+
resourceNotFound(ctx: BaseContext): void;
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-exceptions",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.90.0",
|
|
4
4
|
"description": "Platform exceptions module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
|
-
"main": "./lib/index.js",
|
|
8
|
-
"typings": "./lib/index.d.ts",
|
|
7
|
+
"main": "./lib/cjs/index.js",
|
|
8
|
+
"typings": "./lib/types/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"import": "./lib/esm/index.js",
|
|
12
|
+
"require": "./lib/cjs/index.js",
|
|
13
|
+
"default": "./lib/esm/index.js"
|
|
12
14
|
},
|
|
13
15
|
"scripts": {
|
|
14
|
-
"build": "
|
|
16
|
+
"build": "yarn run build:esm && yarn run build:cjs",
|
|
17
|
+
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
18
|
+
"build:esm": "tsc --build tsconfig.compile.esm.json"
|
|
15
19
|
},
|
|
16
20
|
"dependencies": {
|
|
17
21
|
"tslib": "2.2.0"
|
|
18
22
|
},
|
|
19
23
|
"devDependencies": {
|
|
20
|
-
"@tsed/core": "6.
|
|
21
|
-
"@tsed/di": "6.
|
|
22
|
-
"@tsed/exceptions": "6.
|
|
23
|
-
"@tsed/schema": "6.
|
|
24
|
+
"@tsed/core": "6.90.0",
|
|
25
|
+
"@tsed/di": "6.90.0",
|
|
26
|
+
"@tsed/exceptions": "6.90.0",
|
|
27
|
+
"@tsed/schema": "6.90.0"
|
|
24
28
|
},
|
|
25
29
|
"peerDependencies": {
|
|
26
|
-
"@tsed/core": "^6.
|
|
27
|
-
"@tsed/di": "^6.
|
|
28
|
-
"@tsed/exceptions": "^6.
|
|
29
|
-
"@tsed/schema": "^6.
|
|
30
|
+
"@tsed/core": "^6.90.0",
|
|
31
|
+
"@tsed/di": "^6.90.0",
|
|
32
|
+
"@tsed/exceptions": "^6.90.0",
|
|
33
|
+
"@tsed/schema": "^6.90.0"
|
|
30
34
|
},
|
|
31
35
|
"repository": "https://github.com/tsedio/tsed",
|
|
32
36
|
"bugs": {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.compile.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"module": "ES2020",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"outDir": "./lib/esm",
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationDir": "./lib/types"
|
|
10
|
+
},
|
|
11
|
+
"exclude": [
|
|
12
|
+
"node_modules",
|
|
13
|
+
"test",
|
|
14
|
+
"lib",
|
|
15
|
+
"benchmark",
|
|
16
|
+
"coverage",
|
|
17
|
+
"spec",
|
|
18
|
+
"**/*.benchmark.ts",
|
|
19
|
+
"**/*.spec.ts",
|
|
20
|
+
"keys",
|
|
21
|
+
"jest.config.js"
|
|
22
|
+
]
|
|
23
|
+
}
|
package/lib/index.js
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
var tslib = require('tslib');
|
|
2
|
-
var di = require('@tsed/di');
|
|
3
|
-
var Exceptions = require('@tsed/exceptions');
|
|
4
|
-
var core = require('@tsed/core');
|
|
5
|
-
var schema = require('@tsed/schema');
|
|
6
|
-
|
|
7
|
-
function _interopNamespace(e) {
|
|
8
|
-
if (e && e.__esModule) return e;
|
|
9
|
-
var n = Object.create(null);
|
|
10
|
-
if (e) {
|
|
11
|
-
Object.keys(e).forEach(function (k) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () {
|
|
17
|
-
return e[k];
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
n['default'] = e;
|
|
24
|
-
return n;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var Exceptions__namespace = /*#__PURE__*/_interopNamespace(Exceptions);
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @ignore
|
|
31
|
-
*/
|
|
32
|
-
// tslint:disable-next-line:variable-name
|
|
33
|
-
const ExceptionFiltersContainer = new Map();
|
|
34
|
-
/**
|
|
35
|
-
* @ignore
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
function registerExceptionType(type, token) {
|
|
39
|
-
ExceptionFiltersContainer.set(type, token);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Register a new class to handle an specific exception.
|
|
44
|
-
* @decorator
|
|
45
|
-
* @param types
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
function Catch(...types) {
|
|
49
|
-
return target => {
|
|
50
|
-
types.forEach(type => {
|
|
51
|
-
registerExceptionType(type, target);
|
|
52
|
-
});
|
|
53
|
-
di.registerProvider({
|
|
54
|
-
provide: target,
|
|
55
|
-
useClass: target
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const toHTML = (message = "") => message.replace(/\n/gi, "<br />");
|
|
61
|
-
|
|
62
|
-
exports.StringErrorFilter = class StringErrorFilter {
|
|
63
|
-
catch(error, ctx) {
|
|
64
|
-
ctx.response.status(404).body(toHTML(error));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
};
|
|
68
|
-
exports.StringErrorFilter = tslib.__decorate([Catch(String)], exports.StringErrorFilter);
|
|
69
|
-
|
|
70
|
-
function _extends() {
|
|
71
|
-
_extends = Object.assign || function (target) {
|
|
72
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
73
|
-
var source = arguments[i];
|
|
74
|
-
|
|
75
|
-
for (var key in source) {
|
|
76
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
77
|
-
target[key] = source[key];
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return target;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
return _extends.apply(this, arguments);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
exports.ErrorFilter = class ErrorFilter {
|
|
89
|
-
catch(error, ctx) {
|
|
90
|
-
const {
|
|
91
|
-
response,
|
|
92
|
-
logger,
|
|
93
|
-
env
|
|
94
|
-
} = ctx;
|
|
95
|
-
const err = this.mapError(error, env);
|
|
96
|
-
logger.error({
|
|
97
|
-
error: _extends({}, err, {
|
|
98
|
-
stack: error.stack
|
|
99
|
-
})
|
|
100
|
-
});
|
|
101
|
-
response.setHeaders(this.getHeaders(error)).status(err.status).contentType("application/json").body(env === core.Env.PROD ? "InternalServerError" : err);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
mapError(error, env) {
|
|
105
|
-
var _error$origin;
|
|
106
|
-
|
|
107
|
-
return {
|
|
108
|
-
name: ((_error$origin = error.origin) == null ? void 0 : _error$origin.name) || error.name,
|
|
109
|
-
message: error.message,
|
|
110
|
-
status: error.status || 500,
|
|
111
|
-
errors: this.getErrors(error),
|
|
112
|
-
stack: env === core.Env.DEV ? error.stack : undefined
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
getErrors(error) {
|
|
117
|
-
return [error, error.origin].filter(Boolean).reduce((errs, {
|
|
118
|
-
errors
|
|
119
|
-
}) => {
|
|
120
|
-
return errs.concat(errors).filter(Boolean);
|
|
121
|
-
}, []);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
getHeaders(error) {
|
|
125
|
-
return [error, error.origin].filter(Boolean).reduce((obj, {
|
|
126
|
-
headers
|
|
127
|
-
}) => {
|
|
128
|
-
return _extends({}, obj, headers || {});
|
|
129
|
-
}, {});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
};
|
|
133
|
-
exports.ErrorFilter = tslib.__decorate([Catch(Error)], exports.ErrorFilter);
|
|
134
|
-
|
|
135
|
-
exports.ExceptionFilter = class ExceptionFilter extends exports.ErrorFilter {
|
|
136
|
-
catch(error, ctx) {
|
|
137
|
-
const {
|
|
138
|
-
response,
|
|
139
|
-
logger,
|
|
140
|
-
env
|
|
141
|
-
} = ctx;
|
|
142
|
-
const err = this.mapError(error, env);
|
|
143
|
-
logger.error({
|
|
144
|
-
error: err,
|
|
145
|
-
stack: error.stack
|
|
146
|
-
});
|
|
147
|
-
response.setHeaders(this.getHeaders(error)).contentType("application/json").status(error.status).body(err);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
};
|
|
151
|
-
exports.ExceptionFilter = tslib.__decorate([Catch(Exceptions.Exception)], exports.ExceptionFilter);
|
|
152
|
-
|
|
153
|
-
exports.MongooseErrorFilter = class MongooseErrorFilter extends exports.ErrorFilter {
|
|
154
|
-
catch(error, ctx) {
|
|
155
|
-
return super.catch(new Exceptions.BadRequest(error.message, error), ctx);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
};
|
|
159
|
-
exports.MongooseErrorFilter = tslib.__decorate([Catch("MongooseError", "MongoError")], exports.MongooseErrorFilter);
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* @ignore
|
|
163
|
-
*/
|
|
164
|
-
|
|
165
|
-
const ErrorSchema = schema.object({
|
|
166
|
-
name: schema.string().required().description("The error name"),
|
|
167
|
-
message: schema.string().required().description("An error message")
|
|
168
|
-
}).label("GenericError").unknown();
|
|
169
|
-
schema.from(Exceptions.Exception).properties({
|
|
170
|
-
name: schema.string().required().description("The error name"),
|
|
171
|
-
message: schema.string().required().description("An error message"),
|
|
172
|
-
status: schema.number().required().description("The status code of the exception"),
|
|
173
|
-
errors: schema.array().items(ErrorSchema).description("A list of related errors"),
|
|
174
|
-
stack: schema.string().description("The stack trace (only in development mode)")
|
|
175
|
-
}); // Auto load models for all Exceptions
|
|
176
|
-
|
|
177
|
-
Object.values(Exceptions__namespace).forEach(target => {
|
|
178
|
-
if (target !== Exceptions.Exception && target.STATUS) {
|
|
179
|
-
if (target.STATUS > 302) {
|
|
180
|
-
const name = schema.getStatusConstant(target.STATUS);
|
|
181
|
-
schema.from(target).properties({
|
|
182
|
-
name: schema.string().required().example(name).default(name).description("The error name"),
|
|
183
|
-
status: schema.number().required().example(target.STATUS).default(target.STATUS).description("The status code of the exception")
|
|
184
|
-
});
|
|
185
|
-
schema.defineStatusModel(target.STATUS, target);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
class ResourceNotFound extends Exceptions.NotFound {
|
|
191
|
-
constructor(url) {
|
|
192
|
-
super(`Resource "${url}" not found`);
|
|
193
|
-
this.url = url;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Catch all errors and return the json error with the right status code when it's possible.
|
|
200
|
-
*
|
|
201
|
-
* @platform
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
exports.PlatformExceptions = class PlatformExceptions {
|
|
205
|
-
constructor() {
|
|
206
|
-
this.types = new Map();
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
$onInit() {
|
|
210
|
-
ExceptionFiltersContainer.forEach((token, type) => {
|
|
211
|
-
this.types.set(type, this.injector.get(token));
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
catch(error, ctx) {
|
|
216
|
-
const name = core.nameOf(core.classOf(error));
|
|
217
|
-
|
|
218
|
-
if (name && this.types.has(name)) {
|
|
219
|
-
return this.types.get(name).catch(error, ctx);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const target = core.ancestorsOf(error).reverse().find(target => this.types.has(target));
|
|
223
|
-
|
|
224
|
-
if (target) {
|
|
225
|
-
return this.types.get(target).catch(error, ctx);
|
|
226
|
-
} // default
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return this.types.get(Error).catch(error, ctx);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
resourceNotFound(ctx) {
|
|
233
|
-
return this.catch(new ResourceNotFound(ctx.request.url), ctx);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
tslib.__decorate([di.Inject(), tslib.__metadata("design:type", di.InjectorService)], exports.PlatformExceptions.prototype, "injector", void 0);
|
|
239
|
-
|
|
240
|
-
exports.PlatformExceptions = tslib.__decorate([di.Injectable({
|
|
241
|
-
imports: [exports.ErrorFilter, exports.ExceptionFilter, exports.MongooseErrorFilter, exports.StringErrorFilter]
|
|
242
|
-
})], exports.PlatformExceptions);
|
|
243
|
-
|
|
244
|
-
exports.Catch = Catch;
|
|
245
|
-
exports.ExceptionFiltersContainer = ExceptionFiltersContainer;
|
|
246
|
-
exports.ResourceNotFound = ResourceNotFound;
|
|
247
|
-
exports.registerExceptionType = registerExceptionType;
|
|
248
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/domain/ExceptionFiltersContainer.ts","../src/decorators/catch.ts","../src/components/StringErrorFilter.ts","../src/components/ErrorFilter.ts","../src/components/ExceptionFilter.ts","../src/components/MongooseErrorFilter.ts","../src/domain/ExceptionSchema.ts","../src/errors/ResourceNotFound.ts","../src/services/PlatformExceptions.ts"],"sourcesContent":["import {Type} from \"@tsed/core\";\nimport type {ExceptionFilterMethods} from \"../interfaces/ExceptionFilterMethods\";\n/**\n * @ignore\n */\nexport type ExceptionFilterKey = Type<any> | Symbol | string;\n/**\n * @ignore\n */\n// tslint:disable-next-line:variable-name\nexport const ExceptionFiltersContainer = new Map<ExceptionFilterKey, Type<ExceptionFilterMethods>>();\n/**\n * @ignore\n */\nexport function registerExceptionType(type: ExceptionFilterKey, token: Type<ExceptionFilterMethods>) {\n ExceptionFiltersContainer.set(type, token);\n}\n","import {Type} from \"@tsed/core\";\nimport {registerProvider} from \"@tsed/di\";\nimport {registerExceptionType} from \"../domain/ExceptionFiltersContainer\";\n\n/**\n * Register a new class to handle an specific exception.\n * @decorator\n * @param types\n */\nexport function Catch(...types: (Type<Error | any> | string)[]) {\n return (target: any) => {\n types.forEach((type) => {\n registerExceptionType(type, target as any);\n });\n registerProvider({\n provide: target,\n useClass: target\n });\n };\n}\n","import {BaseContext} from \"@tsed/di\";\nimport {Catch} from \"../decorators/catch\";\nimport type {ExceptionFilterMethods} from \"../interfaces/ExceptionFilterMethods\";\n\nconst toHTML = (message = \"\") => message.replace(/\\n/gi, \"<br />\");\n\n@Catch(String)\nexport class StringErrorFilter implements ExceptionFilterMethods {\n catch(error: string, ctx: BaseContext): void {\n ctx.response.status(404).body(toHTML(error));\n }\n}\n","import {Env} from \"@tsed/core\";\nimport {BaseContext} from \"@tsed/di\";\nimport {Catch} from \"../decorators/catch\";\nimport type {ExceptionFilterMethods} from \"../interfaces/ExceptionFilterMethods\";\n\n@Catch(Error)\nexport class ErrorFilter implements ExceptionFilterMethods {\n catch(error: any, ctx: BaseContext): void {\n const {response, logger, env} = ctx;\n const err = this.mapError(error, env);\n\n logger.error({\n error: {...err, stack: error.stack}\n });\n\n response\n .setHeaders(this.getHeaders(error))\n .status(err.status)\n .contentType(\"application/json\")\n .body(env === Env.PROD ? \"InternalServerError\" : err);\n }\n\n mapError(error: any, env?: Env) {\n return {\n name: error.origin?.name || error.name,\n message: error.message,\n status: error.status || 500,\n errors: this.getErrors(error),\n stack: env === Env.DEV ? error.stack : undefined\n };\n }\n\n protected getErrors(error: any) {\n return [error, error.origin].filter(Boolean).reduce((errs, {errors}: any) => {\n return errs.concat(errors).filter(Boolean);\n }, []);\n }\n\n protected getHeaders(error: any) {\n return [error, error.origin].filter(Boolean).reduce((obj, {headers}: any) => {\n return {\n ...obj,\n ...(headers || {})\n };\n }, {});\n }\n}\n","import {BaseContext} from \"@tsed/di\";\nimport {Exception} from \"@tsed/exceptions\";\nimport {Catch} from \"../decorators/catch\";\nimport {ErrorFilter} from \"./ErrorFilter\";\n\n@Catch(Exception)\nexport class ExceptionFilter extends ErrorFilter {\n catch(error: Exception, ctx: BaseContext) {\n const {response, logger, env} = ctx;\n const err = this.mapError(error, env);\n logger.error({\n error: err,\n stack: error.stack\n });\n\n response.setHeaders(this.getHeaders(error)).contentType(\"application/json\").status(error.status).body(err);\n }\n}\n","import {BaseContext} from \"@tsed/di\";\nimport {BadRequest} from \"@tsed/exceptions\";\nimport {Catch} from \"../decorators/catch\";\nimport {ErrorFilter} from \"./ErrorFilter\";\n\n@Catch(\"MongooseError\", \"MongoError\")\nexport class MongooseErrorFilter extends ErrorFilter {\n catch(error: Error, ctx: BaseContext) {\n return super.catch(new BadRequest(error.message, error), ctx);\n }\n}\n","import * as Exceptions from \"@tsed/exceptions\";\nimport {Exception} from \"@tsed/exceptions\";\nimport {array, defineStatusModel, from, getStatusConstant, number, object, string} from \"@tsed/schema\";\n\n/**\n * @ignore\n */\nconst ErrorSchema = object({\n name: string().required().description(\"The error name\"),\n message: string().required().description(\"An error message\")\n})\n .label(\"GenericError\")\n .unknown();\n\nfrom(Exception).properties({\n name: string().required().description(\"The error name\"),\n message: string().required().description(\"An error message\"),\n status: number().required().description(\"The status code of the exception\"),\n errors: array().items(ErrorSchema).description(\"A list of related errors\"),\n stack: string().description(\"The stack trace (only in development mode)\")\n});\n\n// Auto load models for all Exceptions\nObject.values(Exceptions).forEach((target: any) => {\n if (target !== Exception && target.STATUS) {\n if (target.STATUS > 302) {\n const name = getStatusConstant(target.STATUS);\n from(target).properties({\n name: string().required().example(name).default(name).description(\"The error name\"),\n status: number().required().example(target.STATUS).default(target.STATUS).description(\"The status code of the exception\")\n });\n\n defineStatusModel(target.STATUS, target);\n }\n }\n});\n","import {NotFound} from \"@tsed/exceptions\";\n\nexport class ResourceNotFound extends NotFound {\n readonly url: string;\n\n constructor(url: string) {\n super(`Resource \"${url}\" not found`);\n\n this.url = url;\n }\n}\n","import {ancestorsOf, classOf, nameOf} from \"@tsed/core\";\nimport {BaseContext, Inject, Injectable, InjectorService} from \"@tsed/di\";\nimport {ErrorFilter} from \"../components/ErrorFilter\";\nimport {ExceptionFilter} from \"../components/ExceptionFilter\";\nimport {MongooseErrorFilter} from \"../components/MongooseErrorFilter\";\nimport {StringErrorFilter} from \"../components/StringErrorFilter\";\nimport {ExceptionFilterKey, ExceptionFiltersContainer} from \"../domain/ExceptionFiltersContainer\";\nimport {ResourceNotFound} from \"../errors/ResourceNotFound\";\nimport {ExceptionFilterMethods} from \"../interfaces/ExceptionFilterMethods\";\n\n/**\n * Catch all errors and return the json error with the right status code when it's possible.\n *\n * @platform\n */\n@Injectable({\n imports: [ErrorFilter, ExceptionFilter, MongooseErrorFilter, StringErrorFilter]\n})\nexport class PlatformExceptions {\n types: Map<ExceptionFilterKey, ExceptionFilterMethods> = new Map();\n\n @Inject()\n injector: InjectorService;\n\n $onInit() {\n ExceptionFiltersContainer.forEach((token, type) => {\n this.types.set(type, this.injector.get(token)!);\n });\n }\n\n catch(error: unknown, ctx: BaseContext) {\n const name = nameOf(classOf(error));\n\n if (name && this.types.has(name)) {\n return this.types.get(name)!.catch(error, ctx);\n }\n\n const target = ancestorsOf(error)\n .reverse()\n .find((target) => this.types.has(target));\n\n if (target) {\n return this.types.get(target)!.catch(error, ctx);\n }\n\n // default\n return this.types.get(Error)!.catch(error, ctx);\n }\n\n resourceNotFound(ctx: BaseContext) {\n return this.catch(new ResourceNotFound(ctx.request.url), ctx);\n }\n}\n"],"names":["ExceptionFiltersContainer","Map","registerExceptionType","type","token","set","Catch","types","target","forEach","registerProvider","provide","useClass","toHTML","message","replace","StringErrorFilter","catch","error","ctx","response","status","body","String","ErrorFilter","logger","env","err","mapError","stack","setHeaders","getHeaders","contentType","Env","PROD","name","origin","errors","getErrors","DEV","undefined","filter","Boolean","reduce","errs","concat","obj","headers","Error","ExceptionFilter","Exception","MongooseErrorFilter","BadRequest","ErrorSchema","object","string","required","description","label","unknown","from","properties","number","array","items","Object","values","Exceptions","STATUS","getStatusConstant","example","default","defineStatusModel","ResourceNotFound","NotFound","constructor","url","PlatformExceptions","$onInit","injector","get","nameOf","classOf","has","ancestorsOf","reverse","find","resourceNotFound","request","__decorate","Inject","InjectorService","Injectable","imports"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;;AAGA;MACaA,yBAAyB,GAAG,IAAIC,GAAJ;AACzC;;;;SAGgBC,sBAAsBC,MAA0BC;AAC9DJ,EAAAA,yBAAyB,CAACK,GAA1B,CAA8BF,IAA9B,EAAoCC,KAApC;AACD;;ACZD;;;;;;SAKgBE,MAAM,GAAGC;AACvB,SAAQC,MAAD;AACLD,IAAAA,KAAK,CAACE,OAAN,CAAeN,IAAD;AACZD,MAAAA,qBAAqB,CAACC,IAAD,EAAOK,MAAP,CAArB;AACD,KAFD;AAGAE,IAAAA,mBAAgB,CAAC;AACfC,MAAAA,OAAO,EAAEH,MADM;AAEfI,MAAAA,QAAQ,EAAEJ;AAFK,KAAD,CAAhB;AAID,GARD;AASD;;ACfD,MAAMK,MAAM,GAAG,CAACC,OAAO,GAAG,EAAX,KAAkBA,OAAO,CAACC,OAAR,CAAgB,MAAhB,EAAwB,QAAxB,CAAjC;;AAGaC,yBAAiB,GAA9B,MAAaA,iBAAb;AACEC,EAAAA,KAAK,CAACC,KAAD,EAAgBC,GAAhB;AACHA,IAAAA,GAAG,CAACC,QAAJ,CAAaC,MAAb,CAAoB,GAApB,EAAyBC,IAAzB,CAA8BT,MAAM,CAACK,KAAD,CAApC;AACD;;;AAHUF,yBAAiB,qBAD7BV,KAAK,CAACiB,MAAD,IACOP,0BAAA;;;;;;;;;;;;;;;;;;;;ACDAQ,mBAAW,GAAxB,MAAaA,WAAb;AACEP,EAAAA,KAAK,CAACC,KAAD,EAAaC,GAAb;AACH,UAAM;AAAC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