koa-timeout-middleware
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Koa Timeout Middleware

A Koa middleware to handle requests timeouts

How it works | Install | Usage

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

Readme

Keywords

Package Sidebar

Install

npm i koa-timeout-middleware

Weekly Downloads

8

Version

1.0.1

License

ISC

Unpacked Size

4.83 kB

Total Files

6

Last publish

Collaborators

  • h1b9b