express-async-support

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i express-async-support

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

2.36 kB

Total Files

4

Last publish

Collaborators

  • stayknight