send/server/routes/metadata.js

21 lines
460 B
JavaScript
Raw Normal View History

const storage = require('../storage');
module.exports = async function(req, res) {
const id = req.params.id;
2018-02-06 22:31:18 +00:00
const meta = req.meta;
try {
if (meta.dead && !meta.flagged) {
return res.sendStatus(404);
}
const ttl = await storage.ttl(id);
res.send({
metadata: meta.metadata,
flagged: !!meta.flagged,
2020-07-27 18:18:52 +00:00
finalDownload: meta.dlToken + 1 === meta.dlimit,
ttl
});
} catch (e) {
res.sendStatus(404);
}
};