send/server/routes/delete.js

25 lines
589 B
JavaScript
Raw Normal View History

const storage = require('../storage');
2019-02-12 19:50:06 +00:00
const { statDeleteEvent } = require('../amplitude');
module.exports = async function(req, res) {
try {
2019-02-12 19:50:06 +00:00
const id = req.params.id;
const meta = req.meta;
const ttl = await storage.ttl(id);
await storage.kill(id);
2018-02-06 22:31:18 +00:00
res.sendStatus(200);
2019-02-12 19:50:06 +00:00
statDeleteEvent({
id,
ip: req.ip,
country: req.geo.country,
state: req.geo.state,
2019-02-12 19:50:06 +00:00
owner: meta.owner,
download_count: meta.dl,
2019-05-03 16:25:12 +00:00
ttl,
agent: req.ua.browser.name || req.ua.ua.substring(0, 6)
2019-02-12 19:50:06 +00:00
});
} catch (e) {
res.sendStatus(404);
}
};