0.0.3 • Published 5 years ago

@koex/onerror v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

onerror

NPM version Coverage Status Dependencies Build Status license issues

onerror for koa extend.

Install

$ npm install @koex/onerror

Usage

// See more in test
import onerror from '@koex/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