@tsed/platform-exceptions 7.18.2 → 7.18.3

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.
Files changed (31) hide show
  1. package/.eslintignore +13 -0
  2. package/.eslintrc.js +1 -0
  3. package/jest.config.js +2 -2
  4. package/lib/cjs/components/ErrorFilter.js.map +1 -1
  5. package/lib/cjs/components/ExceptionFilter.js.map +1 -1
  6. package/lib/cjs/components/MongooseErrorFilter.js.map +1 -1
  7. package/lib/cjs/components/StringErrorFilter.js.map +1 -1
  8. package/lib/cjs/decorators/catch.js.map +1 -1
  9. package/lib/cjs/domain/ExceptionFiltersContainer.js.map +1 -1
  10. package/lib/cjs/domain/ExceptionSchema.js.map +1 -1
  11. package/lib/cjs/errors/ResourceNotFound.js.map +1 -1
  12. package/lib/cjs/index.js.map +1 -1
  13. package/lib/cjs/interfaces/ExceptionFilterMethods.js.map +1 -1
  14. package/lib/cjs/services/PlatformExceptions.js.map +1 -1
  15. package/lib/esm/components/ErrorFilter.js.map +1 -1
  16. package/lib/esm/components/ExceptionFilter.js.map +1 -1
  17. package/lib/esm/components/MongooseErrorFilter.js.map +1 -1
  18. package/lib/esm/components/StringErrorFilter.js.map +1 -1
  19. package/lib/esm/decorators/catch.js.map +1 -1
  20. package/lib/esm/domain/ExceptionFiltersContainer.js.map +1 -1
  21. package/lib/esm/domain/ExceptionSchema.js.map +1 -1
  22. package/lib/esm/errors/ResourceNotFound.js.map +1 -1
  23. package/lib/esm/index.js.map +1 -1
  24. package/lib/esm/interfaces/ExceptionFilterMethods.js.map +1 -1
  25. package/lib/esm/services/PlatformExceptions.js.map +1 -1
  26. package/lib/tsconfig.esm.tsbuildinfo +1 -0
  27. package/lib/tsconfig.tsbuildinfo +1 -0
  28. package/lib/types/domain/ExceptionFiltersContainer.d.ts +1 -1
  29. package/package.json +18 -14
  30. package/tsconfig.esm.json +42 -0
  31. package/tsconfig.compile.esm.json +0 -12
package/.eslintignore ADDED
@@ -0,0 +1,13 @@
1
+ node_modules
2
+ docs
3
+ docs-references
4
+ lib
5
+ dist
6
+ coverage
7
+ .nyc_output
8
+ *-lock.json
9
+ *.lock
10
+ benchmarks.*
11
+ **/generated
12
+
13
+ **/*.js
package/.eslintrc.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require("@tsed/eslint/node.js");
package/jest.config.js CHANGED
@@ -2,11 +2,11 @@
2
2
  // https://jestjs.io/docs/en/configuration.html
3
3
 
4
4
  module.exports = {
5
- ...require("@tsed/jest-config")(__dirname, "platform-exceptions"),
5
+ ...require("@tsed/jest-config"),
6
6
  coverageThreshold: {
7
7
  global: {
8
8
  statements: 100,
9
- branches: 94.73,
9
+ branches: 95.34,
10
10
  functions: 100,
11
11
  lines: 100
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorFilter.js","sourceRoot":"","sources":["../../../src/components/ErrorFilter.ts"],"names":[],"mappings":";;;;AAAA,qCAA+B;AAE/B,+CAA0C;AAI1C,IAAa,WAAW,GAAxB,MAAa,WAAW;IACtB,KAAK,CAAC,KAAU,EAAE,GAAgB;QAChC,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAC,GAAG,GAAG,CAAC;QACpC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAEtC,MAAM,CAAC,KAAK,CAAC;YACX,KAAK,EAAE,EAAC,GAAG,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAC;SACpC,CAAC,CAAC;QAEH,QAAQ;aACL,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;aAClC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;aAClB,WAAW,CAAC,kBAAkB,CAAC;aAC/B,IAAI,CAAC,GAAG,KAAK,UAAG,CAAC,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC;IAED,QAAQ,CAAC,KAAU,EAAE,GAAS;QAC5B,OAAO;YACL,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,IAAI,IAAI,KAAK,CAAC,IAAI;YACtC,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,GAAG;YAC3B,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAC7B,KAAK,EAAE,GAAG,KAAK,UAAG,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SACjD,CAAC;IACJ,CAAC;IAES,SAAS,CAAC,KAAU;QAC5B,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAC,MAAM,EAAM,EAAE,EAAE;YAC1E,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;IAES,UAAU,CAAC,KAAU;QAC7B,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAC,OAAO,EAAM,EAAE,EAAE;YAC1E,OAAO;gBACL,GAAG,GAAG;gBACN,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;aACnB,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF,CAAA;AAxCY,WAAW;IADvB,IAAA,aAAK,EAAC,KAAK,CAAC;GACA,WAAW,CAwCvB;AAxCY,kCAAW","sourcesContent":["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"]}
1
+ {"version":3,"file":"ErrorFilter.js","sourceRoot":"","sources":["../../../src/components/ErrorFilter.ts"],"names":[],"mappings":";;;;AAAA,qCAA+B;AAE/B,+CAA0C;AAInC,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,KAAK,CAAC,KAAU,EAAE,GAAgB;QAChC,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAC,GAAG,GAAG,CAAC;QACpC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAEtC,MAAM,CAAC,KAAK,CAAC;YACX,KAAK,EAAE,EAAC,GAAG,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAC;SACpC,CAAC,CAAC;QAEH,QAAQ;aACL,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;aAClC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;aAClB,WAAW,CAAC,kBAAkB,CAAC;aAC/B,IAAI,CAAC,GAAG,KAAK,UAAG,CAAC,IAAI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":"","sources":["../../../src/components/ExceptionFilter.ts"],"names":[],"mappings":";;;;AACA,iDAA2C;AAC3C,+CAA0C;AAC1C,+CAA0C;AAG1C,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,yBAAW;IAC9C,KAAK,CAAC,KAAgB,EAAE,GAAgB;QACtC,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAC,GAAG,GAAG,CAAC;QACpC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACtC,MAAM,CAAC,KAAK,CAAC;YACX,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC;QAEH,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7G,CAAC;CACF,CAAA;AAXY,eAAe;IAD3B,IAAA,aAAK,EAAC,sBAAS,CAAC;GACJ,eAAe,CAW3B;AAXY,0CAAe","sourcesContent":["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"]}
1
+ {"version":3,"file":"ExceptionFilter.js","sourceRoot":"","sources":["../../../src/components/ExceptionFilter.ts"],"names":[],"mappings":";;;;AACA,iDAA2C;AAC3C,+CAA0C;AAC1C,+CAA0C;AAGnC,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,yBAAW;IAC9C,KAAK,CAAC,KAAgB,EAAE,GAAgB;QACtC,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAC,GAAG,GAAG,CAAC;QACpC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACtC,MAAM,CAAC,KAAK,CAAC;YACX,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC;QAEH,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7G,CAAC;CACF,CAAA;AAXY,eAAe;IAD3B,IAAA,aAAK,EAAC,sBAAS,CAAC;GACJ,eAAe,CAW3B;AAXY,0CAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"MongooseErrorFilter.js","sourceRoot":"","sources":["../../../src/components/MongooseErrorFilter.ts"],"names":[],"mappings":";;;;AACA,iDAA4C;AAC5C,+CAA0C;AAC1C,+CAA0C;AAG1C,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,yBAAW;IAClD,KAAK,CAAC,KAAY,EAAE,GAAgB;QAClC,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,uBAAU,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;CACF,CAAA;AAJY,mBAAmB;IAD/B,IAAA,aAAK,EAAC,eAAe,EAAE,YAAY,CAAC;GACxB,mBAAmB,CAI/B;AAJY,kDAAmB","sourcesContent":["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"]}
1
+ {"version":3,"file":"MongooseErrorFilter.js","sourceRoot":"","sources":["../../../src/components/MongooseErrorFilter.ts"],"names":[],"mappings":";;;;AACA,iDAA4C;AAC5C,+CAA0C;AAC1C,+CAA0C;AAGnC,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,yBAAW;IAClD,KAAK,CAAC,KAAY,EAAE,GAAgB;QAClC,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,uBAAU,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;CACF,CAAA;AAJY,mBAAmB;IAD/B,IAAA,aAAK,EAAC,eAAe,EAAE,YAAY,CAAC;GACxB,mBAAmB,CAI/B;AAJY,kDAAmB"}
@@ -1 +1 @@
1
- {"version":3,"file":"StringErrorFilter.js","sourceRoot":"","sources":["../../../src/components/StringErrorFilter.ts"],"names":[],"mappings":";;;;AACA,+CAA0C;AAG1C,MAAM,MAAM,GAAG,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAGnE,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAC5B,KAAK,CAAC,KAAa,EAAE,GAAgB;QACnC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AAJY,iBAAiB;IAD7B,IAAA,aAAK,EAAC,MAAM,CAAC;GACD,iBAAiB,CAI7B;AAJY,8CAAiB","sourcesContent":["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"]}
1
+ {"version":3,"file":"StringErrorFilter.js","sourceRoot":"","sources":["../../../src/components/StringErrorFilter.ts"],"names":[],"mappings":";;;;AACA,+CAA0C;AAG1C,MAAM,MAAM,GAAG,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAG5D,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,KAAK,CAAC,KAAa,EAAE,GAAgB;QACnC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AAJY,iBAAiB;IAD7B,IAAA,aAAK,EAAC,MAAM,CAAC;GACD,iBAAiB,CAI7B;AAJY,8CAAiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"catch.js","sourceRoot":"","sources":["../../../src/decorators/catch.ts"],"names":[],"mappings":";;;AACA,iCAA0C;AAC1C,mFAA0E;AAE1E;;;;GAIG;AACH,SAAgB,KAAK,CAAC,GAAG,KAAqC;IAC5D,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,IAAA,iDAAqB,EAAC,IAAI,EAAE,MAAa,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,IAAA,qBAAgB,EAAC;YACf,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,MAAM;SACjB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAVD,sBAUC","sourcesContent":["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"]}
1
+ {"version":3,"file":"catch.js","sourceRoot":"","sources":["../../../src/decorators/catch.ts"],"names":[],"mappings":";;;AACA,iCAA0C;AAC1C,mFAA0E;AAE1E;;;;GAIG;AACH,SAAgB,KAAK,CAAC,GAAG,KAAqC;IAC5D,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,IAAA,iDAAqB,EAAC,IAAI,EAAE,MAAa,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,IAAA,qBAAgB,EAAC;YACf,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,MAAM;SACjB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAVD,sBAUC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ExceptionFiltersContainer.js","sourceRoot":"","sources":["../../../src/domain/ExceptionFiltersContainer.ts"],"names":[],"mappings":";;;AAMA;;GAEG;AACH,yCAAyC;AAC5B,QAAA,yBAAyB,GAAG,IAAI,GAAG,EAAoD,CAAC;AACrG;;GAEG;AACH,SAAgB,qBAAqB,CAAC,IAAwB,EAAE,KAAmC;IACjG,iCAAyB,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC;AAFD,sDAEC","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"]}
1
+ {"version":3,"file":"ExceptionFiltersContainer.js","sourceRoot":"","sources":["../../../src/domain/ExceptionFiltersContainer.ts"],"names":[],"mappings":";;;AAMA;;GAEG;AACH,yCAAyC;AAC5B,QAAA,yBAAyB,GAAG,IAAI,GAAG,EAAoD,CAAC;AACrG;;GAEG;AACH,SAAgB,qBAAqB,CAAC,IAAwB,EAAE,KAAmC;IACjG,iCAAyB,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC;AAFD,sDAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ExceptionSchema.js","sourceRoot":"","sources":["../../../src/domain/ExceptionSchema.ts"],"names":[],"mappings":";;;AAAA,qEAA+C;AAC/C,iDAA2C;AAC3C,yCAAuG;AAEvG;;GAEG;AACH,MAAM,WAAW,GAAG,IAAA,eAAM,EAAC;IACzB,IAAI,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,gBAAgB,CAAC;IACvD,OAAO,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kBAAkB,CAAC;CAC7D,CAAC;KACC,KAAK,CAAC,cAAc,CAAC;KACrB,OAAO,EAAE,CAAC;AAEb,IAAA,aAAI,EAAC,sBAAS,CAAC,CAAC,UAAU,CAAC;IACzB,IAAI,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,gBAAgB,CAAC;IACvD,OAAO,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kBAAkB,CAAC;IAC5D,MAAM,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kCAAkC,CAAC;IAC3E,MAAM,EAAE,IAAA,cAAK,GAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,0BAA0B,CAAC;IAC1E,KAAK,EAAE,IAAA,eAAM,GAAE,CAAC,WAAW,CAAC,4CAA4C,CAAC;CAC1E,CAAC,CAAC;AAEH,sCAAsC;AACtC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,MAAW,EAAE,EAAE;IAChD,IAAI,MAAM,KAAK,sBAAS,IAAI,MAAM,CAAC,MAAM,EAAE;QACzC,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;YACvB,MAAM,IAAI,GAAG,IAAA,0BAAiB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC9C,IAAA,aAAI,EAAC,MAAM,CAAC,CAAC,UAAU,CAAC;gBACtB,IAAI,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,gBAAgB,CAAC;gBACnF,MAAM,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,kCAAkC,CAAC;aAC1H,CAAC,CAAC;YAEH,IAAA,0BAAiB,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SAC1C;KACF;AACH,CAAC,CAAC,CAAC","sourcesContent":["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"]}
1
+ {"version":3,"file":"ExceptionSchema.js","sourceRoot":"","sources":["../../../src/domain/ExceptionSchema.ts"],"names":[],"mappings":";;;AAAA,qEAA+C;AAC/C,iDAA2C;AAC3C,yCAAuG;AAEvG;;GAEG;AACH,MAAM,WAAW,GAAG,IAAA,eAAM,EAAC;IACzB,IAAI,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,gBAAgB,CAAC;IACvD,OAAO,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kBAAkB,CAAC;CAC7D,CAAC;KACC,KAAK,CAAC,cAAc,CAAC;KACrB,OAAO,EAAE,CAAC;AAEb,IAAA,aAAI,EAAC,sBAAS,CAAC,CAAC,UAAU,CAAC;IACzB,IAAI,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,gBAAgB,CAAC;IACvD,OAAO,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kBAAkB,CAAC;IAC5D,MAAM,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kCAAkC,CAAC;IAC3E,MAAM,EAAE,IAAA,cAAK,GAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,0BAA0B,CAAC;IAC1E,KAAK,EAAE,IAAA,eAAM,GAAE,CAAC,WAAW,CAAC,4CAA4C,CAAC;CAC1E,CAAC,CAAC;AAEH,sCAAsC;AACtC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,MAAW,EAAE,EAAE;IAChD,IAAI,MAAM,KAAK,sBAAS,IAAI,MAAM,CAAC,MAAM,EAAE;QACzC,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;YACvB,MAAM,IAAI,GAAG,IAAA,0BAAiB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC9C,IAAA,aAAI,EAAC,MAAM,CAAC,CAAC,UAAU,CAAC;gBACtB,IAAI,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,gBAAgB,CAAC;gBACnF,MAAM,EAAE,IAAA,eAAM,GAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,kCAAkC,CAAC;aAC1H,CAAC,CAAC;YAEH,IAAA,0BAAiB,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SAC1C;KACF;AACH,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ResourceNotFound.js","sourceRoot":"","sources":["../../../src/errors/ResourceNotFound.ts"],"names":[],"mappings":";;;AAAA,iDAA0C;AAE1C,MAAa,gBAAiB,SAAQ,qBAAQ;IACnC,GAAG,CAAS;IAErB,YAAY,GAAW;QACrB,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC,CAAC;QAErC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF;AARD,4CAQC","sourcesContent":["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"]}
1
+ {"version":3,"file":"ResourceNotFound.js","sourceRoot":"","sources":["../../../src/errors/ResourceNotFound.ts"],"names":[],"mappings":";;;AAAA,iDAA0C;AAE1C,MAAa,gBAAiB,SAAQ,qBAAQ;IACnC,GAAG,CAAS;IAErB,YAAY,GAAW;QACrB,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC,CAAC;QAErC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF;AARD,4CAQC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,mEAAyC;AACzC,uEAA6C;AAC7C,2EAAiD;AACjD,yEAA+C;AAC/C,6DAAmC;AACnC,6EAAmD;AACnD,mEAAyC;AACzC,oEAA0C;AAC1C,8EAAoD;AACpD,wEAA8C","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./components/ErrorFilter\";\nexport * from \"./components/ExceptionFilter\";\nexport * from \"./components/MongooseErrorFilter\";\nexport * from \"./components/StringErrorFilter\";\nexport * from \"./decorators/catch\";\nexport * from \"./domain/ExceptionFiltersContainer\";\nexport * from \"./domain/ExceptionSchema\";\nexport * from \"./errors/ResourceNotFound\";\nexport * from \"./interfaces/ExceptionFilterMethods\";\nexport * from \"./services/PlatformExceptions\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,mEAAyC;AACzC,uEAA6C;AAC7C,2EAAiD;AACjD,yEAA+C;AAC/C,6DAAmC;AACnC,6EAAmD;AACnD,mEAAyC;AACzC,oEAA0C;AAC1C,8EAAoD;AACpD,wEAA8C"}
@@ -1 +1 @@
1
- {"version":3,"file":"ExceptionFilterMethods.js","sourceRoot":"","sources":["../../../src/interfaces/ExceptionFilterMethods.ts"],"names":[],"mappings":"","sourcesContent":["import {DIContext} from \"@tsed/di\";\n\nexport interface ExceptionFilterMethods<T = unknown> {\n catch(error: T, ctx: DIContext): void;\n}\n"]}
1
+ {"version":3,"file":"ExceptionFilterMethods.js","sourceRoot":"","sources":["../../../src/interfaces/ExceptionFilterMethods.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformExceptions.js","sourceRoot":"","sources":["../../../src/services/PlatformExceptions.ts"],"names":[],"mappings":";;;;AAAA,qCAAwD;AACxD,iCAAqF;AACrF,2DAAsD;AACtD,mEAA8D;AAC9D,2EAAsE;AACtE,uEAAkE;AAClE,mFAAkG;AAClG,iEAA4D;AAG5D;;;;GAIG;AAIH,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAC7B,KAAK,GAAoD,IAAI,GAAG,EAAE,CAAC;IAGnE,QAAQ,CAAkB;IAE1B,OAAO;QACL,qDAAyB,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,GAAc;QAClC,MAAM,IAAI,GAAG,IAAA,aAAM,EAAC,IAAA,cAAO,EAAC,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,IAAA,kBAAW,EAAC,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,GAAc;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,mCAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;CACF,CAAA;AA9BC;IADC,IAAA,WAAM,GAAE;sCACC,oBAAe;oDAAC;AAJf,kBAAkB;IAH9B,IAAA,eAAU,EAAC;QACV,OAAO,EAAE,CAAC,yBAAW,EAAE,iCAAe,EAAE,yCAAmB,EAAE,qCAAiB,CAAC;KAChF,CAAC;GACW,kBAAkB,CAkC9B;AAlCY,gDAAkB","sourcesContent":["import {ancestorsOf, classOf, nameOf} from \"@tsed/core\";\nimport {BaseContext, DIContext, 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: DIContext) {\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: DIContext) {\n return this.catch(new ResourceNotFound(ctx.request.url), ctx);\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformExceptions.js","sourceRoot":"","sources":["../../../src/services/PlatformExceptions.ts"],"names":[],"mappings":";;;;AAAA,qCAAwD;AACxD,iCAAqF;AACrF,2DAAsD;AACtD,mEAA8D;AAC9D,2EAAsE;AACtE,uEAAkE;AAClE,mFAAkG;AAClG,iEAA4D;AAG5D;;;;GAIG;AAII,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,KAAK,GAAoD,IAAI,GAAG,EAAE,CAAC;IAGnE,QAAQ,CAAkB;IAE1B,OAAO;QACL,qDAAyB,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,GAAc;QAClC,MAAM,IAAI,GAAG,IAAA,aAAM,EAAC,IAAA,cAAO,EAAC,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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AC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAC,OAAO,EAAM,EAAE,EAAE;YAC1E,OAAO;gBACL,GAAG,GAAG;gBACN,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;aACnB,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF,CAAA;AAxCY,WAAW;IADvB,KAAK,CAAC,KAAK,CAAC;GACA,WAAW,CAwCvB;SAxCY,WAAW","sourcesContent":["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"]}
1
+ {"version":3,"file":"ErrorFilter.js","sourceRoot":"","sources":["../../../src/components/ErrorFilter.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,YAAY,CAAC;AAE/B,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAInC,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,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C7G,CAAC;CACF,CAAA;AAXY,eAAe;IAD3B,KAAK,CAAC,SAAS,CAAC;GACJ,eAAe,CAW3B;SAXY,eAAe","sourcesContent":["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"]}
1
+ {"version":3,"file":"ExceptionFilter.js","sourceRoot":"","sources":["../../../src/components/ExceptionFilter.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAGnC,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,WAAW;IAC9C,KAAK,CAAC,KAAgB,EAAE,GAAgB;QACtC,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAC,GAAG,GAAG,CAAC;QACpC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACtC,MAAM,CAAC,KAAK,CAAC;YACX,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC;QAEH,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7G,CAAC;CACF,CAAA;AAXY,eAAe;IAD3B,KAAK,CAAC,SAAS,CAAC;GACJ,eAAe,CAW3B;SAXY,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"MongooseErrorFilter.js","sourceRoot":"","sources":["../../../src/components/MongooseErrorFilter.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAG1C,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,WAAW;IAClD,KAAK,CAAC,KAAY,EAAE,GAAgB;QAClC,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;CACF,CAAA;AAJY,mBAAmB;IAD/B,KAAK,CAAC,eAAe,EAAE,YAAY,CAAC;GACxB,mBAAmB,CAI/B;SAJY,mBAAmB","sourcesContent":["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"]}
1
+ {"version":3,"file":"MongooseErrorFilter.js","sourceRoot":"","sources":["../../../src/components/MongooseErrorFilter.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAGnC,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,WAAW;IAClD,KAAK,CAAC,KAAY,EAAE,GAAgB;QAClC,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;CACF,CAAA;AAJY,mBAAmB;IAD/B,KAAK,CAAC,eAAe,EAAE,YAAY,CAAC;GACxB,mBAAmB,CAI/B;SAJY,mBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"file":"StringErrorFilter.js","sourceRoot":"","sources":["../../../src/components/StringErrorFilter.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAG1C,MAAM,MAAM,GAAG,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAGnE,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAC5B,KAAK,CAAC,KAAa,EAAE,GAAgB;QACnC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AAJY,iBAAiB;IAD7B,KAAK,CAAC,MAAM,CAAC;GACD,iBAAiB,CAI7B;SAJY,iBAAiB","sourcesContent":["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"]}
1
+ {"version":3,"file":"StringErrorFilter.js","sourceRoot":"","sources":["../../../src/components/StringErrorFilter.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAG1C,MAAM,MAAM,GAAG,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAG5D,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,KAAK,CAAC,KAAa,EAAE,GAAgB;QACnC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AAJY,iBAAiB;IAD7B,KAAK,CAAC,MAAM,CAAC;GACD,iBAAiB,CAI7B;SAJY,iBAAiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"catch.js","sourceRoot":"","sources":["../../../src/decorators/catch.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,qBAAqB,EAAC,MAAM,qCAAqC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,GAAG,KAAqC;IAC5D,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,qBAAqB,CAAC,IAAI,EAAE,MAAa,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,gBAAgB,CAAC;YACf,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,MAAM;SACjB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["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"]}
1
+ {"version":3,"file":"catch.js","sourceRoot":"","sources":["../../../src/decorators/catch.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,qBAAqB,EAAC,MAAM,qCAAqC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,GAAG,KAAqC;IAC5D,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,qBAAqB,CAAC,IAAI,EAAE,MAAa,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,gBAAgB,CAAC;YACf,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,MAAM;SACjB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ExceptionFiltersContainer.js","sourceRoot":"","sources":["../../../src/domain/ExceptionFiltersContainer.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,yCAAyC;AACzC,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,GAAG,EAAoD,CAAC;AACrG;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAwB,EAAE,KAAmC;IACjG,yBAAyB,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC","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"]}
1
+ {"version":3,"file":"ExceptionFiltersContainer.js","sourceRoot":"","sources":["../../../src/domain/ExceptionFiltersContainer.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,yC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CAAC,WAAW,CAAC,4CAA4C,CAAC;CAC1E,CAAC,CAAC;AAEH,sCAAsC;AACtC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,MAAW,EAAE,EAAE;IAChD,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE;QACzC,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;YACvB,MAAM,IAAI,GAAG,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC9C,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC;gBACtB,IAAI,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,gBAAgB,CAAC;gBACnF,MAAM,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,kCAAkC,CAAC;aAC1H,CAAC,CAAC;YAEH,iBAAiB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SAC1C;KACF;AACH,CAAC,CAAC,CAAC","sourcesContent":["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"]}
1
+ {"version":3,"file":"ExceptionSchema.js","sourceRoot":"","sources":["../../../src/domain/ExceptionSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,cAAc,CAAC;AAEvG;;GAEG;AACH,MAAM,WAAW,GAAG,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,gBAAgB,CAAC;IACvD,OAAO,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kBAAkB,CAAC;CAC7D,CAAC;KACC,KAAK,CAAC,cAAc,CAAC;KACrB,OAAO,EAAE,CAAC;AAEb,IAAI,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC;IACzB,IAAI,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,gBAAgB,CAAC;IACvD,OAAO,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kBAAkB,CAAC;IAC5D,MAAM,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,kCAAkC,CAAC;IAC3E,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,0BAA0B,CAAC;IAC1E,KAAK,EAAE,MAAM,EAAE,CAAC,WAAW,CAAC,4CAA4C,CAAC;CAC1E,CAAC,CAAC;AAEH,sCAAsC;AACtC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,MAAW,EAAE,EAAE;IAChD,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE;QACzC,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;YACvB,MAAM,IAAI,GAAG,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC9C,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC;gBACtB,IAAI,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,gBAAgB,CAAC;gBACnF,MAAM,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,kCAAkC,CAAC;aAC1H,CAAC,CAAC;YAEH,iBAAiB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SAC1C;KACF;AACH,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ResourceNotFound.js","sourceRoot":"","sources":["../../../src/errors/ResourceNotFound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAE1C,MAAM,OAAO,gBAAiB,SAAQ,QAAQ;IACnC,GAAG,CAAS;IAErB,YAAY,GAAW;QACrB,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC,CAAC;QAErC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF","sourcesContent":["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"]}
1
+ {"version":3,"file":"ResourceNotFound.js","sourceRoot":"","sources":["../../../src/errors/ResourceNotFound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAE1C,MAAM,OAAO,gBAAiB,SAAQ,QAAQ;IACnC,GAAG,CAAS;IAErB,YAAY,GAAW;QACrB,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC,CAAC;QAErC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qCAAqC,CAAC;AACpD,cAAc,+BAA+B,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./components/ErrorFilter\";\nexport * from \"./components/ExceptionFilter\";\nexport * from \"./components/MongooseErrorFilter\";\nexport * from \"./components/StringErrorFilter\";\nexport * from \"./decorators/catch\";\nexport * from \"./domain/ExceptionFiltersContainer\";\nexport * from \"./domain/ExceptionSchema\";\nexport * from \"./errors/ResourceNotFound\";\nexport * from \"./interfaces/ExceptionFilterMethods\";\nexport * from \"./services/PlatformExceptions\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qCAAqC,CAAC;AACpD,cAAc,+BAA+B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ExceptionFilterMethods.js","sourceRoot":"","sources":["../../../src/interfaces/ExceptionFilterMethods.ts"],"names":[],"mappings":"","sourcesContent":["import {DIContext} from \"@tsed/di\";\n\nexport interface ExceptionFilterMethods<T = unknown> {\n catch(error: T, ctx: DIContext): void;\n}\n"]}
1
+ {"version":3,"file":"ExceptionFilterMethods.js","sourceRoot":"","sources":["../../../src/interfaces/ExceptionFilterMethods.ts"],"names":[],"mappings":""}
@@ -1 +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,EAAyB,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AACrF,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;IAC7B,KAAK,GAAoD,IAAI,GAAG,EAAE,CAAC;IAGnE,QAAQ,CAAkB;IAE1B,OAAO;QACL,yBAAyB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAChD,IAAI,CAAC,KAAK,CAAC,GAAG,CAA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{ancestorsOf, classOf, nameOf} from \"@tsed/core\";\nimport {BaseContext, DIContext, 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: DIContext) {\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: DIContext) {\n return this.catch(new ResourceNotFound(ctx.request.url), ctx);\n }\n}\n"]}
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,EAAyB,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AACrF,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC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