# express-es7

> Safely use async middleware in express.

Latest version **4.0.0** (published 2019-11-12) · MIT license · 0 weekly downloads

## Install

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

## 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 | 4.0.0 |
| Published | 2019-11-12 |
| First published | 2017-12-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Jesse Feng |
| Maintainers | fengxinming |
| Keywords | express, express-es7, async, await, connect, middleware, es7, node, nodejs |

## Links

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

## Dependencies (3)

- [celia](https://npm.io/package/celia.md) ^6.1.4
- [methods](https://npm.io/package/methods.md) ^1.1.2
- [http-errors](https://npm.io/package/http-errors.md) ^1.6.2

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 4.0.0 (latest) — 2019-11-12
- 3.0.2 — 2019-09-18
- 3.0.1 — 2019-07-23
- 3.0.0 — 2019-05-07
- 2.0.3 — 2018-10-12
- 2.0.2 — 2018-06-02
- 2.0.1 — 2018-05-30
- 2.0.0 — 2018-05-25
- 1.0.0 — 2017-12-29

## README

[![Express Logo](https://www.educationalappstore.com/images/upload/mzl.blyuuakw.png)](http://expressjs.com/)

# express-es7

> Note: Safely use async middleware in express.

---

## Table of contents

  - [Installation](#installation)
  - [Migrating](#migrating)
  - [Extra API](#extra-api)
  - [Usage](#usage)
  - [Examples](#examples)

---

## Installation

```
$ npm install express-es7 --save
```
or
```
$ cnpm install express-es7 --save
```

---

## Migrating

### How to migrate `express` to `express-es7`

```bash

const express = require('express');
const app = express();

// ...

// use "express-es7" instead of "express", that is all

const express = require('express-es7');
const app = express();

```

---

## Extra API

```js

// catch unhandledRejection error
// when using `express` not `express-es7`

const express = require('express');
const { capture, batch } = require('express-es7');
const app = express();

// avoid unhandledRejection error
app.use(capture(async (req, res, next) => {

}));

// batch processing
app.use(batch(middleware1, middleware2, middleware3, ...));

// catch error
app.use((err, req, res, next) => {
  // ...
});

```

---

## Usage

use ES2017 async functions as middleware with express

```bash

const express = require('express-es7');
const app = express();

// use async functions
app.use(async(req, res, next) => {
  // todo your code
  next();
});
// app.use(middleware[, ...middleware]);

// use router
const apiv2 = express.Router();
apiv2.get('/', async(req, res) => {
  // todo your code
});

app.use('/api/v2', apiv2);

// catch error
app.use((err, req, res, next) => {
  // ...
});

```

---

## Examples
  - [demo](examples)

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