sailor-errorify
Version:
Normalize Error for Sailor
62 lines (42 loc) • 1.52 kB
Markdown
<center></center>
# Errorify for Sailor
[](https://travis-ci.org/sailorjs/sailor-errorify)
[](https://david-dm.org/sailorjs/sailor-errorify)
[](https://david-dm.org/sailorjs/sailor-errorify#info=devDependencies)
[](https://www.npmjs.org/package/sailor-errorify)
[](https://www.gittip.com/Kikobeats/)
> Error normalizer for Sailor. Extend [express-validator-errors](https://github.com/ctavan/express-validator) interface.
## Install
```bash
npm install sailor-errorify
```
## Usage
```coffee
errorify = require 'sailor-errorify'
```
or using `sailor` dependency
```coffee
sailor = require 'sailorjs'
errorify = sailor.errorify
```
## API
Ideal for response with error schema, for example:
```coffee
unless user
return errorify
.add 'identifier', translate.get('User.NotFound'), user
.end res, 'notFound'
```
In this case return a `notFound` response:
```json
{
"errors": [
{
"param": "identifier",
"msg": "Identifier doesn't found"
}
]
}
```
## License
MIT © [Kiko Beats](http://kikobeats.com/)