Socket
Book a DemoInstallSign in
Socket

express-async-await

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-async-await

Use [async/await](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) in your routes without polluting / [wrapping](https://medium.com/@Abazhenov/using-async-await-in-express-with-node-8-b8af872c0016) them.

latest
npmnpm
Version
1.1.0
Version published
Weekly downloads
261
-53.64%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

express

FAQs

Package last updated on 09 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts