ladjs/koa-better-timeout

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

koa-better-timeout

build status code coverage code style styled with prettier made with lass license

Response timeout middleware for Koa and Lad (uses Boom by default)

Table of Contents
Install

npm:

install koa-better-timeout

yarn:

 add koa-better-timeout
Usage

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);


Options

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

Contributors

| Name | Website | | ————– | ————————– | | Nick Baugh | http://niftylettuce.com/ |

License

MIT © Nick Baugh


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.