drop.chapril.org-firefoxsend/server/routes/delete.js
2020-07-24 08:32:43 -07:00

23 lines
529 B
JavaScript

const storage = require('../storage');
const { statDeleteEvent } = require('../amplitude');
module.exports = async function(req, res) {
try {
const id = req.params.id;
const meta = req.meta;
const ttl = await storage.ttl(id);
await storage.kill(id);
res.sendStatus(200);
statDeleteEvent({
id,
ip: req.ip,
owner: meta.owner,
download_count: meta.dl,
ttl,
agent: req.ua.browser.name || req.ua.ua.substring(0, 6)
});
} catch (e) {
res.sendStatus(404);
}
};