Skip to content

Instantly share code, notes, and snippets.

@vdeturckheim
Created February 6, 2018 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdeturckheim/28812a9d9a87d33321d53f1562902515 to your computer and use it in GitHub Desktop.
Save vdeturckheim/28812a9d9a87d33321d53f1562902515 to your computer and use it in GitHub Desktop.
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