# express-async-wrapped

> Utility function to wrap async functions for use with express.js

Latest version **1.0.4** (published 2021-09-11) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2021-09-11 |
| First published | 2020-12-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Chris Howie |
| Maintainers | cdhowie |

## Links

- npm: https://www.npmjs.com/package/express-async-wrapped
- Repository: https://github.com/cdhowie/express-async-wrapped
- Homepage: https://github.com/cdhowie/express-async-wrapped#readme
- Issues: https://github.com/cdhowie/express-async-wrapped/issues
- npm.io page: https://npm.io/package/express-async-wrapped

## Recent versions

- 1.0.4 (latest) — 2021-09-11
- 1.0.3 — 2021-08-20
- 1.0.2 — 2021-08-19
- 1.0.1 — 2021-01-05
- 1.0.0 — 2020-12-29

## README

# express-async-wrapped

Function that turns an async (promise) function into a function that can be
passed to express.js as a handler.  Rejections will get forwarded to express.

The function exported by this module can be used to wrap any express.js handler
type:

* Route handlers.
* Param handlers.
* Middleware.
* Error-handling middleware.
* Arrays of any of the above.

## Quick start

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

router.get('/foo', asyncWrap(async (req, res) => {
    res.json(await getSomeData(req));
}));

router.use(asyncWrap(async (req, res, next) => {
    // await ...

    next();
}));

router.param('foo', asyncWrap(async (req, res, next, id) => {
    req.foo = await getTheFoo(id);
    next();
}));

router.use(asyncWrap(async (err, req, res, next) => {
    // await ...

    res.status(500).end();
}));
```

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