Request timeout middleware for Koa
npm install koa-timeout-middleware
A Koa middleware to handle requests timeouts
How it works
|
Install
|
Usage
koa-timeout-middleware usesPromise.race
to race a setTimeout against your Koa middlewares/response.
The middleware is available on npm
``sh`npm install
npm install --save koa-timeout-middlewareyarn install
yarn add koa-timeout-middleware
The middleware can be configured with a _custom_ timeout time and
status code.
`js
import Koa from 'koa'
import { timeout } from 'koa-timeout-middleware'
const app = new Koa()
app.use(timeout(1000)) // 1s timeout
app.use(timeout(1000, { status: 499 })) // 1s timeout with 499 status
``