# p-connect

> WIP - nothing to see here

Latest version **2.0.0** (published 2020-06-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install p-connect
pnpm add p-connect
yarn add p-connect
bun add p-connect
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2020-06-16 |
| First published | 2019-07-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Bret Comnes |
| Maintainers | bret |

## Links

- npm: https://www.npmjs.com/package/p-connect
- Repository: https://github.com/bcomnes/p-connect
- Issues: https://github.com/bcomnes/p-connect/issues
- npm.io page: https://npm.io/package/p-connect

## Recent versions

- 2.0.0 (latest) — 2020-06-16
- 1.1.0 — 2019-09-01
- 1.0.1 — 2019-07-29
- 1.0.0 — 2019-07-29

## README

# p-connect

Converts connect style middleware, routes, errorRoutes to a promise.  Also supports `http-hash-route` style routes.

```console
npm install p-connect
```

## Usage

``` js
const { pMiddleware, route } = require('p-connect')
const bodyParser = require('body-parser')
const pJson = pMiddleware(bodyParser.json())

const asyncRoute = async (req, res) => {
   await pJson(req, res)
   // req.body is now populated
}

app.use(route(asyncRoute))
```

## API

### `pMiddleware(connectMiddleware)`

Convert a callback style middleware to work inside of an asynchronous environment.  Does not return any value, it will just throw if an error occures inside the middleware.

### `route(asyncConnectRoute)`

Converts an async connect route to a callback connect route.

`connectRoute(req, res, next)` should return a promise.  `route(connectRoute) = (req, res, next) => {...}` returns a connect style callback middleware that calls next(err) when asyncConnectRoute throws.  You should still call the `next` callback in async middleware if you want to keep the middleware chain moving.

## License

MIT

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