This package has been deprecated

Author message:

use express-async-errors instead

express-async-await

1.1.0 • Public • Published

express-async-await

Use async/await in your routes without polluting / wrapping them.

Usage

Pass the app to the library and we'll monkey-patch it for you:

const aa = require('express-async-await')
const app = aa(express())
 
app.get('/ok', async function(req, res, next) {
  res.json({hello: 'world'})
})
 
app.get('/no', async function(req, res) {
  res.notSomethingICanRun({hello: 'world'})
})
 
app.use((err, req, res, next) => {
  console.error(err)
 
  res.status(500).send("Ouch!")
})

Now app.$method(route, fn) support async functions out of the box!

(have a look at the example app)

Installation

npm i express-async-await

npm add express-async-await

Readme

Keywords

Package Sidebar

Install

npm i express-async-await

Weekly Downloads

383

Version

1.1.0

License

MIT

Last publish

Collaborators

  • odino