next/server/middleware/90.log.ts

12 lines
310 B
TypeScript

import { log } from "@server/logger";
export default eventHandler(async (ev) => {
const p = log.startTimer();
ev.node.res.on("close", () => {
p.done({
label: "http/request",
message: `{${ev.context.currentUser?.username || "guest"}} | ${ev.method.toLocaleUpperCase()} @ ${ev._path}`,
});
});
});