From b2b5025d331a5b78aa881bed257732bfc9c53ae4 Mon Sep 17 00:00:00 2001 From: Daniel Cadenas Date: Fri, 12 Jul 2024 11:58:58 -0300 Subject: [PATCH] Add news to reserved names, lighter logs --- docker-compose.yml | 8 ++++++++ src/app.js | 12 ++++++++++++ src/logger.js | 9 +++++++++ src/middlewares/forbiddenNames.js | 1 + 4 files changed, 30 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 0d3955b..b72edb6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,14 @@ version: "3.8" services: + server: + build: . + ports: + - "3000:3000" + environment: + - NODE_ENV=development + - REDIS_HOST=redis + - ROOT_DOMAIN=localhost redis: image: redis:7.2.4 ports: diff --git a/src/app.js b/src/app.js index 968af55..a7919a1 100644 --- a/src/app.js +++ b/src/app.js @@ -31,6 +31,18 @@ app.use( pinoHTTP({ logger, quietReqLogger: true, + autoLogging: { + ignorePaths: ["/metrics"], + }, + serializers: { + req: (req) => ({ + id: req.id, + method: req.method, + url: req.url, + query: req.query, + params: req.params, + }), + }, }) ); diff --git a/src/logger.js b/src/logger.js index 06cfa31..9ec9773 100644 --- a/src/logger.js +++ b/src/logger.js @@ -5,4 +5,13 @@ export default pino({ level: config.logLevel, timestamp: pino.stdTimeFunctions.isoTime, prettyPrint: false, // Ensuring logs are in JSON format, single-line + serializers: { + req: (req) => ({ + id: req.id, + method: req.method, + url: req.url, + query: req.query, + params: req.params, + }), + }, }); diff --git a/src/middlewares/forbiddenNames.js b/src/middlewares/forbiddenNames.js index ea76cc4..d2719fb 100644 --- a/src/middlewares/forbiddenNames.js +++ b/src/middlewares/forbiddenNames.js @@ -54,6 +54,7 @@ const reservedNames = [ /^matt$/, /^mattlorentz$/, /^mplorentz$/, + /^news$/, /^notifications$/, /^operations$/, /^ops$/,