@salsita/koa-error-middleware

1.1.2 • Public • Published

@salsita/koa-error-middleware

NPM version Downloads Licence Dependency Status devDependency Status

Top level middleware for catching and displaying errors (assumes using error classes from @salsita/errors).

Expects logging function as parameter.

Example:

const winston = require("winston");
const Router = require("koa-router");
const errorMiddleware = require("@salsita/koa-error-middleware");

const formatUserMessage = err =>
  process.env.NODE_ENV === "production" ? "Ooops something went wrong" : err.message;

const router = new Router();
router.use(errorMiddleware(winston.log, formatUserMessage));

Readme

Keywords

none

Package Sidebar

Install

npm i @salsita/koa-error-middleware

Weekly Downloads

0

Version

1.1.2

License

MIT

Unpacked Size

2.47 kB

Total Files

3

Last publish

Collaborators