http-system-logger 1.0.13 → 1.0.14

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.
@@ -1,4 +1,4 @@
1
1
  /// <reference types="qs" />
2
- import { Request, Response } from 'express';
2
+ import { Request, Response } from "express";
3
3
  declare const morganMiddleware: (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, callback: (err?: Error | undefined) => void) => void;
4
4
  export default morganMiddleware;
@@ -29,19 +29,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const morgan_1 = __importDefault(require("morgan"));
30
30
  const winston_config_1 = require("./winston.config");
31
31
  const uuid = __importStar(require("uuid"));
32
- const ignoredRoutesRaw = (process.env.IGNORED_ROUTES || '/api/health')
33
- .split(',')
34
- .map((route) => route.trim());
35
- const ignoredRoutesExact = ignoredRoutesRaw.filter(route => !route.includes('*'));
36
- const ignoredRoutesRegex = ignoredRoutesRaw
37
- .filter(route => route.includes('*'))
38
- .map(route => new RegExp('^' + route.replace(/\*/g, '.*') + '$'));
39
- function isIgnoredRoute(path) {
40
- if (ignoredRoutesExact.includes(path))
41
- return true;
42
- return ignoredRoutesRegex.some(regex => regex.test(path));
43
- }
44
32
  const morganMiddleware = (0, morgan_1.default)(function (tokens, req, res) {
33
+ const ignoredRoutesRaw = (process.env.IGNORED_ROUTES || "/api/health")
34
+ .split(",")
35
+ .map((route) => route.trim());
36
+ const ignoredRoutesExact = ignoredRoutesRaw.filter((route) => !route.includes("*"));
37
+ const ignoredRoutesRegex = ignoredRoutesRaw
38
+ .filter((route) => route.includes("*"))
39
+ .map((route) => new RegExp("^" + route.replace(/\*/g, ".*") + "$"));
40
+ function isIgnoredRoute(path) {
41
+ if (ignoredRoutesExact.includes(path))
42
+ return true;
43
+ return ignoredRoutesRegex.some((regex) => regex.test(path));
44
+ }
45
45
  if (isIgnoredRoute(req.path)) {
46
46
  return null; // Skip logging for ignored routes
47
47
  }
@@ -49,19 +49,19 @@ const morganMiddleware = (0, morgan_1.default)(function (tokens, req, res) {
49
49
  method: tokens.method(req, res),
50
50
  url: tokens.url(req, res),
51
51
  status: Number.parseFloat(tokens.status(req, res)),
52
- content_length: tokens.res(req, res, 'content-length'),
53
- response_time: Number.parseFloat(tokens['response-time'](req, res)),
54
- http_version: tokens['http-version'](req, res),
55
- user_agent: tokens['user-agent'](req, res),
52
+ content_length: tokens.res(req, res, "content-length"),
53
+ response_time: Number.parseFloat(tokens["response-time"](req, res)),
54
+ http_version: tokens["http-version"](req, res),
55
+ user_agent: tokens["user-agent"](req, res),
56
56
  request_body: req.body,
57
- id: tokens.req(req, res, 'x-request-id') || uuid.v4(),
57
+ id: tokens.req(req, res, "x-request-id") || uuid.v4(),
58
58
  });
59
59
  }, {
60
60
  stream: {
61
61
  // Configure Morgan to use our custom logger with the http severity
62
62
  write: (message) => {
63
63
  if (message) {
64
- (0, winston_config_1.getLogger)().http(message, { context: 'HttpContext' });
64
+ (0, winston_config_1.getLogger)().http(message, { context: "HttpContext" });
65
65
  }
66
66
  },
67
67
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "http-system-logger",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "A lightweight and configurable logging library for Node.js applications, built with winston and morgan.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",