send/server/routes/delete.js

22 lines
404 B
JavaScript
Raw Normal View History

const storage = require('../storage');
module.exports = async function(req, res) {
const id = req.params.id;
2017-11-30 21:41:09 +00:00
const ownerToken = req.body.owner_token || req.body.delete_token;
2017-11-30 21:41:09 +00:00
if (!ownerToken) {
res.sendStatus(404);
return;
}
try {
2017-11-30 21:41:09 +00:00
const err = await storage.delete(id, ownerToken);
if (!err) {
res.sendStatus(200);
}
} catch (e) {
res.sendStatus(404);
}
};