next/server/middleware/90.log.ts

14 lines
324 B
TypeScript

import { log } from "~/lib/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}`,
});
});
});