(root: string)
| 5 | const logTime = createDebugger('vite:time') |
| 6 | |
| 7 | export function timeMiddleware(root: string): Connect.NextHandleFunction { |
| 8 | // Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...` |
| 9 | return function viteTimeMiddleware(req, res, next) { |
| 10 | const start = performance.now() |
| 11 | const end = res.end |
| 12 | res.end = (...args: readonly [any, any?, any?]) => { |
| 13 | logTime?.(`${timeFrom(start)} ${prettifyUrl(req.url!, root)}`) |
| 14 | return end.call(res, ...args) |
| 15 | } |
| 16 | next() |
| 17 | } |
| 18 | } |
no test coverage detected