Created
February 6, 2018 08:45
-
-
Save vdeturckheim/28812a9d9a87d33321d53f1562902515 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.post('/posts', Celebrate.celebrate( | |
{ | |
body: Joi.object().keys({ | |
title: Joi.string().required(), | |
content: Joi.string().required() | |
}) | |
} | |
), | |
(req, res, next) => { | |
console.log('INSERT new post ' + req.body.title); | |
DB.run('INSERT INTO POSTS (TITLE, CONTENT) VALUES (?, ?)', [req.body.title, req.body.content], (err) => { | |
if (err) { | |
return next(err); | |
} | |
res.status(201); | |
res.end(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment