HOTFIX: Missing data would crash the site

This commit is contained in:
2021-07-25 10:35:13 +01:00
parent 1b9e35539e
commit fd1ba06b45
4 changed files with 19 additions and 6 deletions
+13
View File
@@ -1,6 +1,19 @@
const { articles } = require('../database/models');
const route = async (req, res) => {
//check for missing data
if (!req.body.title) {
return res.status(401).end("Missing title");
}
if (!req.body.author) {
return res.status(401).end("Missing author");
}
if (!req.body.body) {
return res.status(401).end("Missing body");
}
//upsert the data
const [instance, created] = await articles.upsert({
title: req.body.title,