feat: add backend
This commit is contained in:
13
apps/server/middlewares/responseTime.ts
Normal file
13
apps/server/middlewares/responseTime.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { Middleware } from './types.ts';
|
||||
import type Koa from 'koa';
|
||||
|
||||
export class ResponseTime implements Middleware {
|
||||
apply(app: Koa): void {
|
||||
app.use(async (ctx, next) => {
|
||||
const start = Date.now();
|
||||
await next();
|
||||
const ms = Date.now() - start;
|
||||
ctx.set('X-Response-Time', `${ms}ms`);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user