Skip to content

stayknight/express-async-support

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published