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

1.0.7 • Public • Published

express-async-wrapper

Enable support for async syntactic sugar in express middlewares and request handlers

NPM Package

npm install @cdellacqua/express-async-wrapper

How To

Whenever an awaited promise rejects, the asyncWrapper will handle the exception passing it to the next available middleware

import { asyncWrapper } from '@cdellacqua/express-async-wrapper';

router.get('/example', asyncWrapper(async (req, res) => {
	await somethingThatReturnsAPromise();
	res.send('done');
}));
import { asyncWrapper } from '@cdellacqua/express-async-wrapper';

app.use(asyncWrapper(async (req, res, next) => {
	await somethingThatReturnsAPromise();
	next();
}));

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.7
    18
    • latest

Version History

Package Sidebar

Install

npm i @cdellacqua/express-async-wrapper

Weekly Downloads

18

Version

1.0.7

License

MIT

Unpacked Size

3.76 kB

Total Files

6

Last publish

Collaborators

  • cdellacqua