Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 61x 61x 61x 61x 150x 754x 754x 754x 754x | import * as responseTime from 'response-time';
import EventEmitter from 'events';
import { REQUEST_TIME } from '../metric-events';
// eslint-disable-next-line @typescript-eslint/naming-convention
const _responseTime = responseTime.default;
export function responseTimeMetrics(eventBus: EventEmitter): any {
return _responseTime((req, res, time) => {
const { statusCode } = res;
const pathname = req.route ? req.baseUrl + req.route.path : '(hidden)';
const timingInfo = {
path: pathname,
method: req.method,
statusCode,
time,
};
eventBus.emit(REQUEST_TIME, timingInfo);
});
}
|