@joellesenne/express-validation-error
v1.0.4
Published
Simple Middleware to manage exceptions within express error in asynchronous
Downloads
5
Maintainers
Readme
Simple Middleware to manage exceptions within express error in asynchronous
🏠 Homepage
Table of Contents generated with DocToc
Prerequisites
- node >=16.0.0
- npm >=7.13.0
Install
Use simple Middleware to manage exceptions for Express @joellesenne/express-async-handler
npm install --save-dev @joellesenne/express-async-handler @joellesenne/express-error-handler
# OR
yarn add -D @joellesenne/express-async-handler @joellesenne/express-error-handler
Usage
const asyncHandler = require('@joellesenne/express-async-handler')
const ValidationError = require('@joellesenne/express-validation-error')
express.get('/', asyncHandler(async (req, res, next) => {
const bar = await foo.findAll();
res.send(bar)
// Create errorHandler
if (!bar) {
return next(new ValidationError("No bar valid", 404));
}
}))
Run tests
mocha test/index.test.js
Author
👤 Joël Lesenne
- Website: https://joellesenne.dev
- Twitter: @joellesenne
- Github: @joellesenne
- LinkedIn: @joellesenne
🤝 Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.
Show your support
Give a ⭐️ if this project helped you!
📝 License
Copyright © 2021 Joël Lesenne. This project is MIT licensed.
This README was generated with ❤️ by readme-md-generator