12 lines
343 B
TypeScript
12 lines
343 B
TypeScript
import { middleware } from "../trpc";
|
|
|
|
const perfMiddleware = middleware(async ({ path, type, next }) => {
|
|
performance.mark("Start");
|
|
const result = await next();
|
|
performance.mark("End");
|
|
performance.measure(`[${result.ok ? "OK" : "ERROR"}][$1] ${type} '${path}'`, "Start", "End");
|
|
return result;
|
|
});
|
|
|
|
export default perfMiddleware;
|