Name: koa-better-timeout
Owner: Lad
Description: Response timeout middleware for Koa and Lad (uses Boom by default)
Created: 2017-09-09 19:29:09.0
Updated: 2017-11-25 09:49:07.0
Pushed: 2017-09-26 09:59:55.0
Homepage: https://lad.js.org
Size: 62
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Response timeout middleware for Koa and Lad (uses Boom by default)
npm:
install koa-better-timeout
yarn:
add koa-better-timeout
Default middleware usage:
t Timeout = require('koa-better-timeout');
..
t timeout = new Timeout();
use(timeout.middleware);
Advanced middleware usage (e.g. using Lad and its @ladjs/i18n middleware) with translated response message:
t Timeout = require('koa-better-timeout');
..
use(async (ctx, next) => {
y {
const timeout = new Timeout({
message: ctx.translate('REQUEST_TIMED_OUT')
});
await timeout.middleware(ctx, next);
catch (err) {
ctx.throw(err);
You can optionally pass an object of options to Timeout(opts)
.
The default option values use Boom and are:
: 6000,
ssage: Boom.clientTimeout().message,
ndResponse: Boom.clientTimeout
| Name | Website | | ————– | ————————– | | Nick Baugh | http://niftylettuce.com/ |