@zcorky/koa-onerror
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

koa-onerror

NPM version Coverage Status Dependencies Build Status license issues

Simple OnError for Koa

Install

$ npm install @zcorky/koa-onerror

Usage

// See more in test
import onerror from '@zcorky/koa-onerror';

import * as Koa from 'koa';
const app = new Koa();

app.use(onerror());

// fallback
app.use(async (ctx) => {
  const error = new Error('Unauthorized');
  (error as any).status = 401;
  throw error;
});

app.listen(8000, '0.0.0.0', () => {
  console.log('koa server start at port: 8000');
});

Related

Readme

Keywords

none

Package Sidebar

Install

npm i @zcorky/koa-onerror

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

6.66 kB

Total Files

5

Last publish

Collaborators

  • uniquecolesmith