Handle user not found on delete

This commit is contained in:
2024-06-22 16:12:18 +08:00
parent 6298a7087c
commit ce51b78b14

View File

@@ -86,6 +86,13 @@ router.put("/:id", async (req, res) => {
router.delete("/:id", async (req, res) => {
let id = req.params.id;
let user = await User.findByPk(id);
if (!user) {
res.sendStatus(404);
return;
}
let num = await User.destroy({
where: { id: id },
});