https://github.com/koajs/response-time
X-Response-Time middleware
https://github.com/koajs/response-time
Last synced: 5 months ago
JSON representation
X-Response-Time middleware
- Host: GitHub
- URL: https://github.com/koajs/response-time
- Owner: koajs
- Created: 2013-08-17T05:24:54.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2025-05-02T13:21:16.000Z (5 months ago)
- Last Synced: 2025-05-03T15:36:06.316Z (5 months ago)
- Language: JavaScript
- Size: 24.4 KB
- Stars: 125
- Watchers: 8
- Forks: 11
- Open Issues: 4
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
- awesome-koa - response-time - X-Response-Time middleware (Middleware)
README
# koa-response-time
[](https://greenkeeper.io/)
X-Response-Time middleware for [koa](https://github.com/koajs/koa). Compatible with [request-received](https://github.com/cabinjs/request-received).
## Installation
```js
$ npm install koa-response-time
```## Usage
Basic usage:
```js
const Koa = require('koa');
const responseTime = require('koa-response-time');
const app = new Koa();app.use(responseTime());
```If you need response high resolution in nano time, set `hrtime` option to `true`:
```js
app.use(responseTime({ hrtime: true }));
```Sample response header with `hrtime = false` (default):
```
X-Response-Time: 153ms
```Sample response header with `hrtime = true`:
```
X-Response-Time: 153.123581ms
```## Note
Best to `.use()` at the _top_ before any other middleware,
to wrap all subsequent middleware.## License
MIT