# express-json-error-handler

> Error handler for express JSON APIs

Latest version **6.1.0** (published 2024-06-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-json-error-handler
pnpm add express-json-error-handler
yarn add express-json-error-handler
bun add express-json-error-handler
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.1.0 |
| Published | 2024-06-16 |
| First published | 2016-11-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=16.0.0 |
| Dependencies | 1 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Noam Okman |
| Maintainers | noamokman |
| Keywords | express, json, error-handler, api, error |

## Links

- npm: https://www.npmjs.com/package/express-json-error-handler
- Repository: https://github.com/noamokman/express-json-error-handler
- Homepage: https://github.com/noamokman/express-json-error-handler#readme
- Issues: https://github.com/noamokman/express-json-error-handler/issues
- npm.io page: https://npm.io/package/express-json-error-handler

## Dependencies (1)

- [lodash-es](https://npm.io/package/lodash-es.md) ^4.17.21

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 6.1.0 (latest) — 2024-06-16
- 6.0.0 — 2024-02-06
- 5.0.4 — 2022-05-20
- 5.0.3 — 2022-04-04
- 5.0.2 — 2022-04-03
- 5.0.1 — 2022-04-03
- 5.0.0 — 2022-04-03
- 4.1.0 — 2021-11-16
- 4.0.0 — 2020-08-25
- 3.1.0 — 2020-08-15
- 3.0.0 — 2019-07-26
- 2.0.1 — 2018-11-18
- 2.0.0 — 2018-05-06
- 1.1.0 — 2018-03-20
- 1.0.0 — 2016-11-01

## README

# express-json-error-handler

Error handler for express JSON APIs

## Install
``` bash
$ npm install express-json-error-handler
```

## Usage

### Example
``` js
import express from 'express';
import {expressJsonErrorHandler} from 'express-json-error-handler';

const app = express();

app.use(expressJsonErrorHandler());

```

## Options

The `expressJsonErrorHandler` function takes an option `options` object that may contain any of
the following keys:

### log

The `log` option, if supplied, is called as `log({err, req, res})` when server errors occur.
#### Example
``` js
import express from 'express';
import {expressJsonErrorHandler} from 'express-json-error-handler';

const app = express();

app.use(expressJsonErrorHandler({
  log({err, req, res}) {
    console.log(err); // The original error object
    console.log(req); // The request object
    console.log(res); // The response object
  }
}));

```

## License

[MIT](LICENSE)

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