koa-better-timeout
Response timeout middleware for Koa and Lad (uses Boom by default)
Table of Contents
Install
npm:
npm install koa-better-timeout
yarn:
yarn add koa-better-timeout
Usage
Default middleware usage:
const Timeout = ; // ... const timeout = ;app;
Advanced middleware usage (e.g. using Lad and its @ladjs/i18n middleware) with translated response message:
const Timeout = ; // ... const timeout = ctx;app;
Options
You can optionally pass an object of options to Timeout(opts)
.
The default option values use Boom and are:
ms: 6000 message: Boommessage sendResponse: BoomclientTimeout
Note that message
can be a function that accepts one argument ctx
. This is useful if you wish to use i18n translation for the response message.
Contributors
Name | Website |
---|---|
Nick Baugh | http://niftylettuce.com/ |