url-request-log
Version:
check request methods process time made easy
21 lines (20 loc) • 564 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.log = (environment) => {
return (req, res, next) => {
if (environment === 'production') {
return next();
}
const initTime = Date.now();
req['myLoggerInit'] = initTime;
next();
req.on('end', () => {
const diff = Date.now() - req['myLoggerInit'];
console.info({
path: req.path,
type: req.method,
time: diff
});
});
};
};