# gc-express-controller-wrapper

> This little library automatically wraps your controller functions into a try catch block and calls the next function when an error occurs with the thrown error data.

Latest version **1.0.6** (published 2020-02-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install gc-express-controller-wrapper
pnpm add gc-express-controller-wrapper
yarn add gc-express-controller-wrapper
bun add gc-express-controller-wrapper
```

## 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.0.6 |
| Published | 2020-02-09 |
| First published | 2020-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | GhostCoder |
| Maintainers | thomassimon |

## Links

- npm: https://www.npmjs.com/package/gc-express-controller-wrapper
- Repository: https://github.com/ghostcoding-devs/express-controller-wrapper
- Homepage: https://github.com/ghostcoding-devs/express-controller-wrapper#readme
- Issues: https://github.com/ghostcoding-devs/express-controller-wrapper/issues
- npm.io page: https://npm.io/package/gc-express-controller-wrapper

## Recent versions

- 1.0.6 (latest) — 2020-02-09
- 1.0.5 — 2020-02-09
- 1.0.1 — 2020-02-09
- 1.0.0 — 2020-02-08

## README

# Gc-Express-controller-wrapper

This little library automatically wraps your controller functions into a try catch block and calls the next function when an error occurs with the thrown error data.


### Installation

```
npm install gc-express-controller-wrapper
```

### Usage


```javascript

  routes.get('/error', controllerUtil(async (_req, res) => {
    const requestData = (await axios.get('https://jsonplaceholder.typicode.com/todos/a')).data
    return res.json({...requestData})
  }))

```

### Usage without express-controller-wrapper


```javascript

  routes.get('/', async (_req, res, next) => {
    try {
      const requestData = (await axios.get('https://jsonplaceholder.typicode.com/todos/1')).data
      return res.json({...requestData})
    } catch(err) {
      next(err)
    }
  })

```

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