Skip to content

Commit

Permalink
docs(readme): filled README
Browse files Browse the repository at this point in the history
  • Loading branch information
noamokman committed Nov 1, 2016
1 parent 01e6eed commit 4a6e8f0
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# express-json-error-handler
# express-json-error-handler [![Build Status](https://travis-ci.org/noamokman/express-json-error-handler.svg?branch=master)](https://travis-ci.org/noamokman/express-json-error-handler) [![Coverage Status](https://coveralls.io/repos/github/noamokman/express-json-error-handler/badge.svg?branch=master)](https://coveralls.io/github/noamokman/express-json-error-handler?branch=master)

Error handler for express JSON APIs


## Installation
``` bash
$ [sudo] npm install express-json-error-handler --save
```

## Usage

### Example
``` js
import express from 'express';
import jsonErrorHandler from 'express-json-error-handler';

const app = express();

app.use(jsonErrorHandler());

```

## Options

The `jsonErrorHandler` 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 jsonErrorHandler from 'express-json-error-handler';

const app = express();

app.use(jsonErrorHandler({
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)

0 comments on commit 4a6e8f0

Please sign in to comment.