Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

express-async-await

odino900MITdeprecated1.1.0

use express-async-errors instead

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

express, async, await, swag

readme

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