Package detail

koa-better-response-time

3imed-jaberi100MIT1.3.0


response-time, x-response-time, middleware, koa

readme

koa-better-response-time


Build Status Coverage Status NPM version License Code Size

Response time for Koa.js. Inspired from response-time with same object options.

The "response time" is defined here as the elapsed time from when a request enters this middleware to when the headers are written out to the client.

Installation

# npm ..
$ npm install koa-better-response-time
# yarn ..
$ yarn add koa-better-response-time

Usage

This is a practical example of how to use.

const Koa = require('koa');
const xResponseTime = require('koa-better-response-time');
const app = new Koa();

// You can pass options object to xResponseTime.
app.use(xResponseTime());

OPTIONS

You can pass an object that contains these keys to the xResponseTime middleware:

  • digits — (Number) The fixed number of digits to include in the output. default to 3 (ex: 2.300ms).
  • headerName — (String) Header name to use. default to 'X-Response-Time'
  • suffix — (Boolean) Display 'ms' beside the time. default to true (ex: 2.300ms vs 2.300).

Note

Best to .use() at the top before any other middleware, to wrap all subsequent middleware.

License


MIT © Imed Jaberi

changelog

CHANGE LOG

v2.0.0 (06 Dec 2024)

  • fix vulnerability by update deps.
  • drop support for all node.js versions less than 18.
  • replace mocha with native node.js test runner.
  • use async/await syntax for the test cases over 'done'.
  • drop support for koa@1.x.x through the 'v1.js' file.

v1.2.0 (24 Apr 2022)

  • fix vulnerability by update deps.
  • drop ci for node 10 and support only 12 - 16.

v1.1.0 (3 Aout 2020)

  • add pure support for koa@1.x.x using generator over async/promise.

v1.0.0 (13 July 2020)