express-async-support
v1.0.0
Published
hack of express to support async handler.
Downloads
1
Maintainers
Readme
A hack of express to support async handler. Slightly Modified from express-async-errors
Install
yarn add express-async-support
Usage
const express = require('express')
require('express-async-support')
app = express()
// directly use async hanlder
app.get('/hello', async (req, res) => {
throw new Error('oops!')
res.send('hello!');
});
// errors thrown from handlers are passed to the error handler
app.use((err, req, res, next) => {
res.status(500);
res.json({ error: err.message });
next(err);
});