koa-response-time is a minimal Koa middleware designed to automatically add an `X-Response-Time` header to HTTP responses. This header indicates the duration it took for the Koa application to process and respond to a request. Currently at version 2.1.0, which was last published over 7 years ago, the package is highly stable and in maintenance mode, with no anticipated new feature development. Its primary differentiator is its simplicity and direct integration into the Koa ecosystem, providing a standard and unobtrusive way to measure request-response cycles. It supports high-resolution timing via an optional `hrtime` configuration for more precise measurements. The package has no external runtime dependencies, ensuring a lean footprint.
npm install koa-response-timeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up a basic Koa application with the `koa-response-time` middleware. It shows how to apply the middleware at the top of the stack and includes an optional configuration for high-resolution timing. The example includes a simulated asynchronous operation to demonstrate the middleware capturing the full request duration before sending a response.
Ensure `app.use(responseTime(...))` is the first middleware applied in your Koa application.
Always use `const responseTime = require('koa-response-time');` for consistent and reliable imports in Node.js environments.Understand that the project is stable but not actively developed. For new features or rapidly evolving requirements, consider alternatives if this poses a limitation.
Change the import to `const responseTime = require('koa-response-time');` if in a CommonJS context, or use `import responseTime = require('koa-response-time');` in TypeScript for CJS interoperability.Verify that `app.use(responseTime());` is present and correctly placed at the beginning of your middleware chain in your Koa application. Check server logs for any early errors preventing middleware execution.
Move `app.use(responseTime());` to be the *first* middleware registered with your Koa application, before any other `app.use()` calls, to ensure it wraps the entire request processing pipeline.
No dependency data recorded yet.