# router-adapter

> The main goal of this package is to separate the http from the logic by adding a simple link between the router and the controller

Latest version **0.5.0** (published 2018-05-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install router-adapter
pnpm add router-adapter
yarn add router-adapter
bun add router-adapter
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2018-05-18 |
| First published | 2017-10-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | * |
| Dependencies | 4 |
| Unpacked size | 17.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Saulo Tauil |
| Maintainers | saulogt |

## Links

- npm: https://www.npmjs.com/package/router-adapter
- Repository: https://github.com/saulogt/router-adapter
- Homepage: https://github.com/saulogt/router-adapter#readme
- Issues: https://github.com/saulogt/router-adapter/issues
- npm.io page: https://npm.io/package/router-adapter

## Dependencies (4)

- [verror](https://npm.io/package/verror.md) ^1.10.0
- [@types/node](https://npm.io/package/@types/node.md) *
- [@types/verror](https://npm.io/package/@types/verror.md) ^1.10.3
- [@types/express](https://npm.io/package/@types/express.md) *

## Recent versions

- 0.5.0 (latest) — 2018-05-18
- 0.4.0 — 2017-12-13
- 0.3.0 — 2017-12-06
- 0.2.0 — 2017-11-01
- 0.1.1 — 2017-10-31
- 0.1.0 — 2017-10-31

## README

# router-adapter

This package is intended to simplify the express router list as well as separate the logic from the http handling.

## Install

`npm i router-adapter --save`

## Usage:


```js
import { routerAdapter } from 'router-adapter'

app.get('/my-entrypoint/:id', routerAdapter((req) => getObject(req.params.id))

```

Instead of this:

```js
app.get('/my-entrypoint/:id', (req, res) => {
  getObject(req.params.id)
  .then((value) => {
    res.status(200).json(value)
  })
  .catch((e) => {
    res.status(500).json(e)
  })
})
```

## Requirements

-The handler function must return a `Promise`
-If you want to return different error codes other than 500, the promise can be rejected with an instance of HttpError.

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