# @simpleview/express-async-handler

> TypeScript compliant express route handler

Latest version **1.0.2** (published 2022-07-05) · ISC license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-07-05 |
| First published | 2022-07-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | owenallenaz@gmail.com |
| Maintainers | mauriciodeleonc, mpcarolin, csarantidessv, mikesan789, owenallenaz, qman33, svjoshua, mkes99, colin.booen, ssmith_sv, aglazebrook, rmaynes |

## Links

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

## Recent versions

- 1.0.2 (latest) — 2022-07-05
- 1.0.1 — 2022-07-05
- 1.0.0 — 2022-07-05

## README

# @simpleview/express-async-handler

Wrap an express handler to properly handle async errors. Same as `npm express-async-handler` but with better typing.

# Installation

```
npm install @simpleview/express-async-handler
```

# Use

### Basic Example

```typescript
import express from "express";
import { asyncWrap } from "@simpleview/express-async-handler";

const app = express();
app.get("/", asyncWrap(async function(req, res, next) {
    // any errors thrown will be passed on to next() automatically
});
```

### With custom typing

In order to get rich typing you'll want to setup some helper types. There are two primary needs for custom typing.

* Customization of the Application locals (`req.app.locals`, `res.app.locals`).
* Customization of the Request (`req.query`, `req.body`, `req.session`).

There is a full example in [examples/custom_typing](examples/custom_typing).

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