MCPcopy
hub / github.com/vitejs/vite / timeMiddleware

Function timeMiddleware

packages/vite/src/node/server/middlewares/time.ts:7–18  ·  view source on GitHub ↗
(root: string)

Source from the content-addressed store, hash-verified

5const logTime = createDebugger('vite:time')
6
7export 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}

Callers 1

_createServerFunction · 0.90

Calls 3

timeFromFunction · 0.90
prettifyUrlFunction · 0.90
nextFunction · 0.85

Tested by

no test coverage detected