@arfedulov/koa-jsonapi-errors
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

koa-jsonapi-errors

Provides koa error handling middleware and a set of erro constructors that are used with this middleware.

Installation

yarn add @arfedulov/koa-jsonapi-errors

Usage

import Koa from 'koa';
import { jsonApiErrors, BadRequest } from '@arfedulov/koa-jsonapi-errors';

const app = new Koa();

app.use(jsonApiErrors);

app.use(async (ctx, next) => {
  throw new BadRequest();
});
/*
  Produce response body:
  {
    errors: [{ status: "400", title: "Bad request" }]
  }
*/

Package Sidebar

Install

npm i @arfedulov/koa-jsonapi-errors

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

41.4 kB

Total Files

17

Last publish

Collaborators

  • arfedulov