# async-express

> Allow async/await syntax in Express routes and middleware

Latest version **0.1.6** (published 2019-06-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install async-express
pnpm add async-express
yarn add async-express
bun add async-express
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2019-06-08 |
| First published | 2019-03-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Chance Hudson |
| Maintainers | jchancehud |
| Keywords | express, async, await, middleware, route |

## Links

- npm: https://www.npmjs.com/package/async-express
- npm.io page: https://npm.io/package/async-express

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 0.1.6 (latest) — 2019-06-08
- 0.1.5 — 2019-06-08
- 0.1.4 — 2019-04-25
- 0.1.3 — 2019-03-31
- 0.1.2 — 2019-03-31
- 0.1.1 — 2019-03-31
- 0.1.0 — 2019-03-31
- 0.0.4 — 2019-03-24
- 0.0.3 — 2019-03-24
- 0.0.2 — 2019-03-24
- 0.0.1 — 2019-03-24

## README

# async-express

Simple middleware wrapper to make Express handlers async compatible.

## Usage

`npm install --save async-express`

In a route

```js
const express = require('express');
const asyncExpress = require('async-express');

const app = express();

// As a route
app.get('/', asyncExpress(async (req, res, next) => {
  // Wait 5 seconds
  await new Promise(r => setTimeout(r, 5000));
  // Send a response
  res.send('Waited 5 seconds successfully');
}));
```

The sample above can be refactored as the following

```js
const express = require('express');
const asyncExpress = require('async-express');

const app = express();

const waitForABit = asyncExpress(async (req, res, next) => {
  // Wait 5 seconds
  await new Promise(r => setTimeout(r, 5000));
  // Send a response
  res.send('Waited 5 seconds successfully');
});

app.get('/', waitForABit);
```

---
_Source: https://npm.io/package/async-express · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
