Skip to content

Commit

Permalink
Add docs for celebrate
Browse files Browse the repository at this point in the history
  • Loading branch information
santiq committed May 4, 2019
1 parent 4b2251b commit 8161eb5
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions README.md
Expand Up @@ -34,14 +34,41 @@ npm run start
```
It uses nodemon for livereloading :peace-fingers:

# API Validation

By using celebrate the req.body schema becomes clary defined at route level, so even frontend devs can read what an API endpoint expects without need to writting a documentation that can get outdated quickly.

```js
route.post('/signup',
celebrate({
body: Joi.object({
name: Joi.string().required(),
email: Joi.string().required(),
password: Joi.string().required(),
}),
}),
controller.signup)
```

**Example error**

```json
{
"errors": {
"message": "child \"email\" fails because [\"email\" is required]"
}
}
```

[Read more about celebrate here](https://github.com/arb/celebrate) and [the Joi validation API](https://github.com/hapijs/joi/blob/v15.0.1/API.md)

# Roadmap
- [ ] API Validation layer (Celebrate+Joi)
- [x] API Validation layer (Celebrate+Joi)
- [ ] Unit tests examples
- [ ] [Cluster mode](https://softwareontheroad.com/nodejs-scalability-issues?utm_source=github&utm_medium=readme)
- [ ] The logging _'layer'_
- [ ] Add ageda dashboard
- [ ] Continuous integration with CircleCI 😍
- [x] Continuous integration with CircleCI 😍
- [ ] Deploys script and docs for AWS Elastic Beanstalk and Heroku
- [ ] Integration test with newman 😉
- [ ] Instructions on typescript debugging with VSCode
Expand Down

0 comments on commit 8161eb5

Please sign in to comment.