Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pdehaan/express-celebrate

Messing around with express and celebrate modules.
https://github.com/pdehaan/express-celebrate

Last synced: 22 days ago
JSON representation

Messing around with express and celebrate modules.

Awesome Lists containing this project

README

        

# Express + Celebrate test

Messing around with [**celebrate**](https://www.npmjs.com/package/celebrate), "an express middleware function that wraps the joi validation library".

```sh
npm start
# Server is started... http://localhost:3000/
```

URLs to test:

1.
OUTPUT: `Hello, {"name":"stranger}`
2.
OUTPUT: `Hello, {"name":"foo"}`
3.
OUTPUT: `Hello, {"name":"foo","age":33}`
4.
OUTPUT: `{"statusCode":400,"error":"Bad Request","message":"\"age\" must be a number","validation":{"source":"query","keys":["age"]}}`
5.
OUTPUT: `{"statusCode":400,"error":"Bad Request","message":"\"status\" is not allowed","validation":{"source":"query","keys":["status"]}}`
6.
OUTPUT: `/name is, "foo"`
7.
OUTPUT: `{"statusCode":400,"error":"Bad Request","message":"\"name\" is required","validation":{"source":"query","keys":["name"]}}`