@decaf-ts/for-nest 0.3.8 → 0.3.10
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/dist/for-nest.cjs +1 -1
- package/dist/for-nest.cjs.map +1 -1
- package/dist/for-nest.js +1 -1
- package/dist/for-nest.js.map +1 -1
- package/lib/esm/factory/errors/throttling.d.ts +4 -0
- package/lib/esm/factory/errors/throttling.js +7 -0
- package/lib/esm/factory/errors/throttling.js.map +1 -0
- package/lib/esm/factory/exceptions/DecafErrorFilter.js +9 -2
- package/lib/esm/factory/exceptions/DecafErrorFilter.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/factory/errors/throttling.cjs +11 -0
- package/lib/factory/errors/throttling.d.ts +4 -0
- package/lib/factory/errors/throttling.js.map +1 -0
- package/lib/factory/exceptions/DecafErrorFilter.cjs +9 -2
- package/lib/factory/exceptions/DecafErrorFilter.js.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ const common_1 = require("@nestjs/common");
|
|
|
11
11
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
12
12
|
const logging_1 = require("@decaf-ts/logging");
|
|
13
13
|
const core_1 = require("@decaf-ts/core");
|
|
14
|
+
const throttling_1 = require("./../errors/throttling.cjs");
|
|
14
15
|
let DecafExceptionFilter = class DecafExceptionFilter {
|
|
15
16
|
catch(exception, host) {
|
|
16
17
|
const ctx = host.switchToHttp();
|
|
@@ -23,8 +24,14 @@ let DecafExceptionFilter = class DecafExceptionFilter {
|
|
|
23
24
|
exception = new common_1.NotAcceptableException(exception.message);
|
|
24
25
|
statusCode = exception.getStatus();
|
|
25
26
|
}
|
|
26
|
-
else if (!(exception instanceof db_decorators_1.BaseError))
|
|
27
|
-
|
|
27
|
+
else if (!(exception instanceof db_decorators_1.BaseError)) {
|
|
28
|
+
if (exception.status === 429) {
|
|
29
|
+
exception = new throttling_1.ToManyRequestsError(exception.message);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
exception = new db_decorators_1.InternalError(exception.message);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
28
35
|
response.status(exception.code || statusCode).json({
|
|
29
36
|
status: exception.code || statusCode,
|
|
30
37
|
error: isProduction ? exception.name : exception.message,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecafErrorFilter.js","sourceRoot":"","sources":["../../../src/factory/exceptions/DecafErrorFilter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAMwB;AACxB,2DAAmE;AACnE,+CAAsD;AACtD,yCAAkD;
|
|
1
|
+
{"version":3,"file":"DecafErrorFilter.js","sourceRoot":"","sources":["../../../src/factory/exceptions/DecafErrorFilter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAMwB;AACxB,2DAAmE;AACnE,+CAAsD;AACtD,yCAAkD;AAClD,2DAA2D;AAGpD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,KAAK,CAAC,SAAgB,EAAE,IAAmB;QACzC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QAEjC,MAAM,YAAY,GAAG,2BAAiB,CAAC,GAAG,KAAK,YAAY,CAAC;QAC5D,IAAI,UAAU,CAAC;QAEf,IACE,SAAS,YAAY,0BAAiB;YACtC,SAAS,YAAY,uBAAgB,EACrC,CAAC;YACD,SAAS,GAAG,IAAI,+BAAsB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YAC1D,UAAU,GAAI,SAAoC,CAAC,SAAS,EAAE,CAAC;QACjE,CAAC;aAAM,IAAI,CAAC,CAAC,SAAS,YAAY,yBAAS,CAAC,EAAE,CAAC;YAC7C,IAAI,SAAiB,CAAC,MAAM,KAAK,GAAG,EAAC,CAAC;gBACpC,SAAS,GAAG,IAAI,gCAAmB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACzD,CAAC;iBAAI,CAAC;gBACJ,SAAS,GAAG,IAAI,6BAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QAED,QAAQ,CAAC,MAAM,CAAE,SAAuB,CAAC,IAAI,IAAI,UAAU,CAAC,CAAC,IAAI,CAAC;YAChE,MAAM,EAAG,SAAuB,CAAC,IAAI,IAAI,UAAU;YACnD,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO;YACxD,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,IAAI,EAAE,OAAO,CAAC,GAAG;YACjB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA/BY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,cAAK,GAAE;GACK,oBAAoB,CA+BhC"}
|
package/lib/index.cjs
CHANGED
|
@@ -57,7 +57,7 @@ __exportStar(require("./events-module/index.cjs"), exports);
|
|
|
57
57
|
* @constant
|
|
58
58
|
* @type {string}
|
|
59
59
|
*/
|
|
60
|
-
exports.VERSION = "0.3.
|
|
60
|
+
exports.VERSION = "0.3.10";
|
|
61
61
|
exports.PACKAGE_NAME = "@decaf-ts/for-nest";
|
|
62
62
|
decoration_1.Metadata.allowReregistration(true);
|
|
63
63
|
decoration_1.Metadata.registerLibrary(exports.PACKAGE_NAME, exports.VERSION);
|
package/lib/index.d.ts
CHANGED