@builder6/core 3.0.2 → 3.0.4

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.
@@ -0,0 +1,5 @@
1
+ import { ExceptionFilter, ArgumentsHost } from '@nestjs/common';
2
+ export declare class AllExceptionsFilter implements ExceptionFilter {
3
+ private logger;
4
+ catch(exception: any, host: ArgumentsHost): void;
5
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var AllExceptionsFilter_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.AllExceptionsFilter = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const ejs_1 = require("ejs");
13
+ const path_1 = require("path");
14
+ let AllExceptionsFilter = AllExceptionsFilter_1 = class AllExceptionsFilter {
15
+ constructor() {
16
+ this.logger = new common_1.Logger(AllExceptionsFilter_1.name);
17
+ }
18
+ catch(exception, host) {
19
+ try {
20
+ const ctx = host.switchToHttp();
21
+ const response = ctx.getResponse();
22
+ const request = ctx.getRequest();
23
+ this.logger.error({
24
+ method: request.method,
25
+ url: request.url,
26
+ headers: request.headers,
27
+ exception,
28
+ }, exception.stack);
29
+ let errorResponse;
30
+ const message = exception?.response?.error?.message ||
31
+ exception?.response?.message ||
32
+ exception.message;
33
+ const code = exception?.response?.error?.code || exception?.code;
34
+ if (exception instanceof common_1.HttpException) {
35
+ errorResponse = {
36
+ status: exception.getStatus(),
37
+ message,
38
+ };
39
+ }
40
+ else {
41
+ errorResponse = {
42
+ message,
43
+ status: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
44
+ };
45
+ }
46
+ const filePath = (0, path_1.join)(__dirname, '..', '..', 'views', 'error.ejs');
47
+ (0, ejs_1.renderFile)(filePath, {
48
+ statusCode: errorResponse.status,
49
+ timestamp: new Date().toISOString(),
50
+ path: request.url,
51
+ message: errorResponse.message,
52
+ code: code,
53
+ }, (err, html) => {
54
+ if (err) {
55
+ response.status(errorResponse.status).json({
56
+ statusCode: errorResponse.status,
57
+ timestamp: new Date().toISOString(),
58
+ path: request.url,
59
+ message: errorResponse.message,
60
+ code: code,
61
+ });
62
+ }
63
+ else {
64
+ response.status(errorResponse.status).send(html);
65
+ }
66
+ });
67
+ }
68
+ catch (error) {
69
+ this.logger.error('Error while processing uncaught exception', error.stack);
70
+ }
71
+ }
72
+ };
73
+ exports.AllExceptionsFilter = AllExceptionsFilter;
74
+ exports.AllExceptionsFilter = AllExceptionsFilter = AllExceptionsFilter_1 = __decorate([
75
+ (0, common_1.Catch)()
76
+ ], AllExceptionsFilter);
77
+ //# sourceMappingURL=all-exceptions.filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"all-exceptions.filter.js","sourceRoot":"","sources":["../../src/filters/all-exceptions.filter.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAOwB;AACxB,6BAAiC;AACjC,+BAA4B;AAQrB,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAAzB;QACG,WAAM,GAAW,IAAI,eAAM,CAAC,qBAAmB,CAAC,IAAI,CAAC,CAAC;IAmEhE,CAAC;IAlEC,KAAK,CAAC,SAAc,EAAE,IAAmB;QACvC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;YACnC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;YAEjC,IAAI,CA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C,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;wBACnC,IAAI,EAAE,OAAO,CAAC,GAAG;wBACjB,OAAO,EAAE,aAAa,CAAC,OAAO;wBAC9B,IAAI,EAAE,IAAI;qBACX,CAAC,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACN,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,2CAA2C,EAC3C,KAAK,CAAC,KAAK,CACZ,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AApEY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,cAAK,GAAE;GACK,mBAAmB,CAoE/B"}
package/dist/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export * from './mongodb';
4
4
  export * from './plugin';
5
5
  export * from './logger/pinoConfig';
6
6
  export * from './websockets';
7
+ export * from './filters/all-exceptions.filter';
package/dist/index.js CHANGED
@@ -20,4 +20,5 @@ __exportStar(require("./mongodb"), exports);
20
20
  __exportStar(require("./plugin"), exports);
21
21
  __exportStar(require("./logger/pinoConfig"), exports);
22
22
  __exportStar(require("./websockets"), exports);
23
+ __exportStar(require("./filters/all-exceptions.filter"), exports);
23
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,2CAAyB;AACzB,4CAA0B;AAC1B,2CAAyB;AACzB,sDAAoC;AACpC,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,2CAAyB;AACzB,4CAA0B;AAC1B,2CAAyB;AACzB,sDAAoC;AACpC,+CAA6B;AAC7B,kEAAgD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder6/core",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "dependencies": {
10
10
  "@aws-sdk/client-cloudwatch-logs": "^3.721.0",
11
- "@builder6/query-mongodb": "3.0.2",
11
+ "@builder6/query-mongodb": "3.0.4",
12
12
  "@socket.io/redis-adapter": "^8.3.0",
13
13
  "moleculer": "^0.14.35",
14
14
  "pino-http": "^10.3.0",
@@ -22,5 +22,5 @@
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
25
- "gitHead": "2fce24b9cf5ecbe759fbd5ed8cb9f16664c3b87e"
25
+ "gitHead": "204178b282c38a08af08645d68ebe802dc3d9f25"
26
26
  }