@liberstudio/cloudflare-list 2.2.3 → 2.2.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.
@@ -10,6 +10,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.CloudflareAttacksModule = void 0;
11
11
  const common_1 = require("@nestjs/common");
12
12
  const axios_1 = require("@nestjs/axios");
13
+ const core_1 = require("@nestjs/core");
14
+ const filters_1 = require("./filters");
13
15
  const attacks_service_1 = require("./attacks.service");
14
16
  const middleware_1 = require("./middleware");
15
17
  const utils_1 = require("./utils");
@@ -55,10 +57,10 @@ exports.CloudflareAttacksModule = CloudflareAttacksModule = CloudflareAttacksMod
55
57
  providers: [
56
58
  attacks_service_1.AttacksService,
57
59
  middleware_1.AttackLoggerMiddleware,
58
- /* {
59
- provide: APP_FILTER,
60
- useClass: AllExceptionsFilter,
61
- }, */
60
+ {
61
+ provide: core_1.APP_FILTER,
62
+ useClass: filters_1.AllExceptionsFilter,
63
+ },
62
64
  ],
63
65
  exports: [attacks_service_1.AttacksService, axios_1.HttpModule],
64
66
  })
@@ -23,7 +23,7 @@ let AllExceptionsFilter = AllExceptionsFilter_1 = class AllExceptionsFilter {
23
23
  // return;
24
24
  // }
25
25
  const status = exception instanceof common_1.HttpException ? exception.getStatus() : common_1.HttpStatus.INTERNAL_SERVER_ERROR;
26
- const message = exception instanceof common_1.HttpException ? exception.getResponse() : "Internal server error";
26
+ const message = exception instanceof common_1.HttpException ? exception.getResponse() : exception instanceof Error ? exception.message : "Internal server error";
27
27
  const ip = (0, get_client_ip_util_1.getClientIp)(request);
28
28
  const errorLog = {
29
29
  ip,
@@ -38,12 +38,12 @@ let AllExceptionsFilter = AllExceptionsFilter_1 = class AllExceptionsFilter {
38
38
  stack: exception instanceof Error ? exception.stack : undefined,
39
39
  };
40
40
  /* const isMissingToken = message === "Invalid or missing token"; */
41
- this.logger.error(`[${ip}] [${request.method}] ${request.url} → ${status}`);
42
- /* if (status >= 500) {
43
- this.logger.error(`[${ip}] [${request.method}] ${request.url} → ${status}`, isMissingToken ? null : JSON.stringify(errorLog, null, 2));
44
- } else {
45
- this.logger.warn(`[${ip}] [${request.method}] ${request.url} → ${status}`, isMissingToken ? null : JSON.stringify(errorLog, null, 2));
46
- } */
41
+ if (status >= 500) {
42
+ this.logger.error(`[${ip}] [${request.method}] ${request.url} → ${status}`, JSON.stringify(errorLog, null, 2));
43
+ }
44
+ else {
45
+ this.logger.warn(`[${ip}] [${request.method}] ${request.url} → ${status}`, JSON.stringify(errorLog, null, 2));
46
+ }
47
47
  response.status(status).json({
48
48
  statusCode: status,
49
49
  timestamp: errorLog.timestamp,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liberstudio/cloudflare-list",
3
- "version": "2.2.3",
3
+ "version": "2.2.4",
4
4
  "description": "Modulo NestJS per gestione IP List Cloudflare",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",