@joellesenne/express-validation-error

1.0.4 • Public • Published

Welcome to @joellesenne/express-validation-error 👋

Documentation Maintenance License: MIT Twitter: joellesenne

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

🤝 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

Package Sidebar

Install

npm i @joellesenne/express-validation-error

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

18.5 kB

Total Files

15

Last publish

Collaborators

  • joellesenne