@forhot2000/express-async-handler
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Simple Middleware to manage exceptions within express routes in asynchronous.

Installation:

npm install --save @forhot2000/express-async-handler

or

yarn add @forhot2000/express-async-handler

Usage:

import asyncHandler from "@forhot2000/express-async-handler"

express.get('/', asyncHandler(async (req, res, next) => {
    const bar = await foo.findAll();
    res.send(bar)
}))

Without express-async-handler

express.get('/',(req, res, next) => {
    foo.findAll()
    .then(bar => {
       res.send(bar)
    })
    .catch(next); // error passed on to the error handling route
})

Package Sidebar

Install

npm i @forhot2000/express-async-handler

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

2.68 kB

Total Files

6

Last publish

Collaborators

  • forhot2000