mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
17 lines
420 B
JavaScript
17 lines
420 B
JavaScript
|
'use strict';
|
||
|
|
||
|
const responseTime = require('response-time');
|
||
|
const { REQUEST_TIME } = require('../events');
|
||
|
|
||
|
module.exports = function(config) {
|
||
|
return responseTime((req, res, time) => {
|
||
|
const timingInfo = {
|
||
|
path: req.baseUrl,
|
||
|
method: req.method,
|
||
|
statusCode: res.statusCode,
|
||
|
time,
|
||
|
};
|
||
|
config.eventBus.emit(REQUEST_TIME, timingInfo);
|
||
|
});
|
||
|
};
|