1.0.1 • Published 3 years ago

koa-timeout-middleware v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
3 years ago

How it works

koa-timeout-middleware uses Promise.race to race a setTimeout against your Koa middlewares/response.

Installation

The middleware is available on npm

# npm install
npm install --save koa-timeout-middleware
# yarn install
yarn add koa-timeout-middleware

Usage

The middleware can be configured with a custom timeout time and status code.

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