@plasticut/express-async-await
v1.0.2
Published
Express.js async/await extention
Downloads
3
Readme
express-async-await
This module adds the ability to handle exceptions that raises in async route handlers.
const {NotFound} = require('http-errors');
require('@plasticut/express-async-await');
const app = require('express')();
app.get('/user/:userId', async (req, res) => {
const user = await User.findById(req.params.userId);
if (!user) throw new NotFound('User not found.');
res.status(200).json(user);
});