Files
auth-service/src/middleware/performance.ts
mifi b969adbc2e
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build was killed
Restructuring the folders
2023-05-24 10:24:39 -04:00

15 lines
435 B
TypeScript

import { Context, Next } from 'koa';
export const performanceLogger = async (ctx: Context, next: Next) => {
await next();
const rt = ctx.response.get('X-Response-Time');
console.log(`${ctx.method} ${ctx.url} - ${rt}`);
};
export const performanceTimer = async (ctx: Context, next: Next) => {
const start = Date.now();
await next();
const ms = Date.now() - start;
ctx.set('X-Response-Time', `${ms}ms`);
};