@yoctol/koa-final-handler
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

koa-final-handler

Build Status npm

Final handler middleware for koa

Installation

Install using npm:

npm install @yoctol/koa-final-handler

Usage

const Koa = require('koa');
const finalHandler = require('@yoctol/koa-final-handler');

const app = new Koa();

app.use(finalHandler());
/* using other middleware after this line */
app.use(auth());
app.use(route());

app.listen(8080, () => {
  console.log('server is running on http://localhost:8080');
});

Response Body

The middleware will append error object on response body when NODE_ENV is development.

const { error } = response.body;

Error Reporting

const handleErrorReporting = (error, ctx) => {
  /* your error reporting handler */
};

app.on('error', handleErrorReporting);

Package Sidebar

Install

npm i @yoctol/koa-final-handler

Weekly Downloads

9

Version

1.0.1

License

MIT

Unpacked Size

4.44 kB

Total Files

4

Last publish

Collaborators

  • link515