Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arfedulov/koa-jsonapi-errors
jsonapi error constructors and error handling middleware for koa
https://github.com/arfedulov/koa-jsonapi-errors
Last synced: 17 days ago
JSON representation
jsonapi error constructors and error handling middleware for koa
- Host: GitHub
- URL: https://github.com/arfedulov/koa-jsonapi-errors
- Owner: arfedulov
- Created: 2019-10-30T13:32:54.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-24T00:44:34.000Z (almost 2 years ago)
- Last Synced: 2024-11-16T14:36:08.641Z (about 2 months ago)
- Language: TypeScript
- Size: 401 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```ts
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" }]
}
*/```