Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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