Kind: Function
Source: src/middleware/timing/timing.ts
Part of: Middleware
End a timer for the timing middleware.
endTime stops the timer managed by the timing middleware when request processing finishes. It pairs with the middleware’s timer start logic to calculate and record timing data for the completed request.
Signature
tsfunction endTime(c: Context, name: string, precision: number)
Parameters
| Name | Type |
|---|---|
c | Context |
name | string |
precision | number |
Diagram
mermaidgraph LR Request[Incoming request] --> Start[Start timing middleware] Start --> Handler[Request handler] Handler --> End[endTime] End --> Timing[Elapsed timing data] Timing --> Response[Completed response]
Usage
tsimport { endTime } from './middleware/timing/timing';
// Call after the request handler has completed and the timer state exists.
function onRequestComplete(request: Request, response: Response) {
endTime(request, response);
}
AI Coding Instructions
- Call
endTimeonly after the timing middleware has initialized timer state for the request. - Keep timer start and end handling within the same request lifecycle.
- Preserve any request or response fields used to store timing data.
- Invoke the function from response completion or middleware flow rather than before handler work has finished.
Was this page helpful?