Home / Function/ timeMiddleware() — vite Function Reference

timeMiddleware() — vite Function Reference

Architecture documentation for the timeMiddleware() function in time.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  09a30669_c2b1_a8b6_7b03_cf1dbb3805ba["timeMiddleware()"]
  19dedcca_e150_aaaf_7737_7db1ac5c1bbb["time.ts"]
  09a30669_c2b1_a8b6_7b03_cf1dbb3805ba -->|defined in| 19dedcca_e150_aaaf_7737_7db1ac5c1bbb
  24ecf2a1_3c09_d451_76f3_9485b4e993f8["_createServer()"]
  24ecf2a1_3c09_d451_76f3_9485b4e993f8 -->|calls| 09a30669_c2b1_a8b6_7b03_cf1dbb3805ba
  14c1c6b3_e4b1_62ce_7196_077ecd00ef57["timeFrom()"]
  09a30669_c2b1_a8b6_7b03_cf1dbb3805ba -->|calls| 14c1c6b3_e4b1_62ce_7196_077ecd00ef57
  0850ad90_f980_60a3_ab1f_b17433109b74["prettifyUrl()"]
  09a30669_c2b1_a8b6_7b03_cf1dbb3805ba -->|calls| 0850ad90_f980_60a3_ab1f_b17433109b74
  style 09a30669_c2b1_a8b6_7b03_cf1dbb3805ba fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/server/middlewares/time.ts lines 7–18

export function timeMiddleware(root: string): Connect.NextHandleFunction {
  // Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
  return function viteTimeMiddleware(req, res, next) {
    const start = performance.now()
    const end = res.end
    res.end = (...args: readonly [any, any?, any?]) => {
      logTime?.(`${timeFrom(start)} ${prettifyUrl(req.url!, root)}`)
      return end.call(res, ...args)
    }
    next()
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does timeMiddleware() do?
timeMiddleware() is a function in the vite codebase, defined in packages/vite/src/node/server/middlewares/time.ts.
Where is timeMiddleware() defined?
timeMiddleware() is defined in packages/vite/src/node/server/middlewares/time.ts at line 7.
What does timeMiddleware() call?
timeMiddleware() calls 2 function(s): prettifyUrl, timeFrom.
What calls timeMiddleware()?
timeMiddleware() is called by 1 function(s): _createServer.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free