Missing new middleware
This commit is contained in:
parent
6857a892f7
commit
8e0366c1ed
10
lib/api/middlewares/log-req-res.js
Normal file
10
lib/api/middlewares/log-req-res.js
Normal file
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function logReqRes ({ logOnEvent = 'finish' } = {}) {
|
||||
return function logReqResMiddleware (req, res, next) {
|
||||
const { logger } = res.locals;
|
||||
logger.info({ client_request: req }, 'Incoming request');
|
||||
res.on(logOnEvent, () => logger.info({ server_response: res, status: res.statusCode }, 'Response sent'));
|
||||
next();
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue
Block a user