Skip to content

plasticut/express-async-await

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);
});

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published