https://github.com/qlaffont/unify-fastify
Fastify error handler with unify-errors
https://github.com/qlaffont/unify-fastify
fastify rest typescript unify-errors
Last synced: 3 months ago
JSON representation
Fastify error handler with unify-errors
- Host: GitHub
- URL: https://github.com/qlaffont/unify-fastify
- Owner: qlaffont
- License: mit
- Created: 2022-05-12T12:50:05.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-04-14T07:48:34.000Z (about 1 year ago)
- Last Synced: 2024-04-14T12:02:53.950Z (about 1 year ago)
- Topics: fastify, rest, typescript, unify-errors
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/unify-fastify
- Size: 1.33 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://codeclimate.com/github/qlaffont/unify-fastify/test_coverage)
[](https://codeclimate.com/github/qlaffont/unify-fastify/maintainability)
   
# Unify FastifyA Fastify plugin wrapping [unify-errors](https://github.com/qlaffont/unify-errors) to handle REST errors. Old Owner: [@flexper](https://github.com/flexper)
## Install
```sh
npm i unify-fastify
# Or
yarn add unify-fastify
# Or
pnpm add unify-fastify
```## Use
```typescript
import fastify from 'fastify'
import unifyFastifyPlugin from 'unify-fastify';
import { BadRequest } from 'unify-errors';const server = fastify()
server.register(unifyFastifyPlugin, { /* options */ })server.get('/bad-request', async () => {
throw new BadRequest({ example: 'A bad request error'})
})
```## Plugin options
| name | default | description |
| ---------------- | ------- | -------------------------------- |
| _disableDetails_ | false | Disable error details like stack |
| _disableLog_ | false | Disable logging on error |## Tests
To execute jest tests (all errors, type integrity test)
```
pnpm test
```## Maintain
This package use [TSdx](https://github.com/jaredpalmer/tsdx). Please check documentation to update this package.