send/server/routes/metadata.js
2020-07-24 08:32:43 -07:00

20 lines
455 B
JavaScript

const storage = require('../storage');
module.exports = async function(req, res) {
const id = req.params.id;
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,
finalDownload: meta.dl + 1 === meta.dlimit,
ttl
});
} catch (e) {
res.sendStatus(404);
}
};