eldimious / express-async-handler

Simple middle to handle exceptions and catch error within express routes in asynchronous and pass them to your express error handlers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Welcome to @dimosbotsaris/express-async-handler 👋

Version Documentation Maintenance Twitter: el_dimious

Simple Express.js middleware to handle exceptions and catch error within express routes in asynchronous and pass them to your express error handlers.

Install

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

Usage

import express, { Request, Response, NextFunction, Router } from 'express';
import { asyncWrapper } from '@dimosbotsaris/express-async-handler';

express.get('/', asyncWrapper(async (req: Request, res: Response, next: NextFunction) => {
  const baz = await foo.findAll();
  res.send(baz)
}))

Run tests

npm run test

Author

👤 Dimos Botsaris

Support Me

ko-fi

Show your support

Give a ⭐️ if this project helped you!

About

Simple middle to handle exceptions and catch error within express routes in asynchronous and pass them to your express error handlers.

License:Apache License 2.0


Languages

Language:TypeScript 76.6%Language:JavaScript 23.4%