Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //...
- {
- method: "POST",
- path: "/v1/books",
- handler: (req, res) => {
- let newBook = new BookSchema(req.payload);
- newBook
- .save()
- .then(book => {
- res(book).code(201);
- })
- .catch(err => {
- res(err);
- });
- },
- config: {
- validate: {
- payload: {
- title: Joi.string().required(),
- author: Joi.string().required(),
- price: Joi.number().required(),
- tags: Joi.array()
- }
- }
- }
- }
- //...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement