const files = require('../../../lib/files'); module.exports = async function (req, res, next) { try { const entity = await files.get(req.params.path, req.params.project, req.query); if (entity) { if (entity.download) { res.download(...entity.download, (err) => next(err)); } else { // Directory listing res.status(203).json(entity); next(); } } else { throw { status: 404, code: "ENOENT" }; } } catch (err) { if (err.code == 'ENOENT') { res.status(404).json({message: err.code}); } else { next(err); } } };