Skip to content

Commit

Permalink
Merge pull request #26 from planetary-social/news_and_lighter_logs
Browse files Browse the repository at this point in the history
Add news to reserved names, lighter logs
  • Loading branch information
dcadenas authored Jul 12, 2024
2 parents ef1ba6a + b2b5025 commit 9339e86
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
},
})
);

Expand Down
9 changes: 9 additions & 0 deletions src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
},
});
1 change: 1 addition & 0 deletions src/middlewares/forbiddenNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const reservedNames = [
/^matt$/,
/^mattlorentz$/,
/^mplorentz$/,
/^news$/,
/^notifications$/,
/^operations$/,
/^ops$/,
Expand Down

0 comments on commit 9339e86

Please sign in to comment.