Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 1 month 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 (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-14T07:48:34.000Z (8 months ago)
- Last Synced: 2024-04-14T12:02:53.950Z (8 months 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
[![Test Coverage](https://api.codeclimate.com/v1/badges/d47a13f51cd7b2e75029/test_coverage)](https://codeclimate.com/github/qlaffont/unify-fastify/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/d47a13f51cd7b2e75029/maintainability)](https://codeclimate.com/github/qlaffont/unify-fastify/maintainability)
![npm](https://img.shields.io/npm/v/unify-fastify) ![npm](https://img.shields.io/npm/dm/unify-fastify) ![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/unify-fastify) ![NPM](https://img.shields.io/npm/l/unify-fastify)
# 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.