
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
express-async-wrapper
Advanced tools
Wrap async express routes so exceptions can be caught by middleware.
If you're using the awesome ES7/ES2017 async/await features in your express routes, you'll notice that when a route throws an exception it times out. This wrapper allows express to properly catch exceptions and pass them to the appropriate error handler instead.
This code was borrowed from the StrongLoop blog post on handling async/await routes in express, I take no credit for coming up with this solution, I just wanted an npm module to use in my apps.
# With npm
npm install --save express-async-wrapper
# With yarn
yarn add express-async-wrapper
If you have a async express route file, like so:
const wrap = require('express-async-wrapper')
module.exports = wrap(async (req, res) => {
const msg = await someSlowNetworkThingy()
res.send('Hello', msg)
})
Now your route properly returns a promise object for express that will catch any throw exceptions.
Licensed under an MIT license by Dana Woodman.
Original source code by StrongLoop (see here)
Pull requests welcome!
FAQs
Wrap async express routes so exceptions can be caught by middleware.
The npm package express-async-wrapper receives a total of 359 weekly downloads. As such, express-async-wrapper popularity was classified as not popular.
We found that express-async-wrapper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.