2017-08-24 21:54:02 +00:00
|
|
|
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-08-24 21:54:02 +00:00
|
|
|
|
2017-11-30 21:41:09 +00:00
|
|
|
if (!ownerToken) {
|
2017-08-24 21:54:02 +00:00
|
|
|
res.sendStatus(404);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2017-11-30 21:41:09 +00:00
|
|
|
const err = await storage.delete(id, ownerToken);
|
2017-08-24 21:54:02 +00:00
|
|
|
if (!err) {
|
|
|
|
res.sendStatus(200);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
res.sendStatus(404);
|
|
|
|
}
|
|
|
|
};
|