# express-async-handler

> Express Error Handler for Async Functions

Latest version **1.2.0** (published 2021-10-15) · MIT license · 0 weekly downloads

## Install

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

## 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.2.0 |
| Published | 2021-10-15 |
| First published | 2017-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 581 |
| Author | Alex Bazhenov |
| Maintainers | abazhenov |
| Keywords | express, async, error middleware, await, error, handling |

## Links

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

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.2.0 (latest) — 2021-10-15
- 1.1.4 — 2018-08-09
- 1.1.3 — 2018-03-23
- 1.1.2 — 2018-03-21
- 1.1.1 — 2018-03-10
- 1.1.0 — 2018-03-10
- 1.0.4 — 2018-02-26
- 1.0.3 — 2018-01-25
- 1.0.2 — 2018-01-13
- 1.0.1 — 2018-01-03
- 1.0.0 — 2017-12-21
- 0.0.2 — 2017-11-30
- 0.0.1 — 2017-11-30

## README

Simple middleware for handling exceptions inside of async express routes and passing them to your express error handlers.

### Installation:

```
npm install --save express-async-handler
```
or
```
yarn add express-async-handler
```

### Usage:

```javascript
const asyncHandler = require('express-async-handler')

express.get('/', asyncHandler(async (req, res, next) => {
	const bar = await foo.findAll();
	res.send(bar)
}))
```

Without express-async-handler

```javascript
express.get('/',(req, res, next) => {
    foo.findAll()
    .then ( bar => {
       res.send(bar)
     } )
    .catch(next); // error passed on to the error handling route
})
```

#### Import in Typescript:

```javascript
import asyncHandler from "express-async-handler"
```

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