Skip to content
Snippets Groups Projects
Commit 83672f17 authored by Renzo Beux's avatar Renzo Beux
Browse files

log on request

parent 7b184808
No related branches found
No related tags found
No related merge requests found
Pipeline #16227 passed
...@@ -40,6 +40,28 @@ app.use(express.raw({ ...@@ -40,6 +40,28 @@ app.use(express.raw({
limit: '50mb', limit: '50mb',
})); }));
app.use((req, res, next) => {
const reqToLog = {
body: { ...req.body },
hostname: req.hostname,
ip: req.ip,
method: req.method,
params: { ...req.params },
path: req.path,
protocol: req.protocol,
query: { ...req.query },
secure: req.secure,
};
// before logging the request, we have to hide sensitive information
if (typeof reqToLog.body.password !== 'undefined') {
reqToLog.body.password = '__HIDDEN__';
}
logger.info('Request received', { request: reqToLog });
next();
});
app.use(Routes); app.use(Routes);
app.use((error: Error, request: Request, response: Response, next: NextFunction) => { app.use((error: Error, request: Request, response: Response, next: NextFunction) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment