Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/koajs/response-time
X-Response-Time middleware
https://github.com/koajs/response-time
Last synced: 2 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 (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-01-16T13:07:53.000Z (almost 2 years ago)
- Last Synced: 2024-05-23T07:01:30.396Z (7 months ago)
- Language: JavaScript
- Size: 21.5 KB
- Stars: 124
- Watchers: 8
- Forks: 13
- Open Issues: 8
-
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
[![Greenkeeper badge](https://badges.greenkeeper.io/koajs/response-time.svg)](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