mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 10:07:08 +00:00
30 lines
692 B
JavaScript
30 lines
692 B
JavaScript
const { bundle } = require('../../../../lib/binary');
|
|
const { sequence } = require('../../../../lib/db');
|
|
|
|
module.exports = async function (req, res, next) {
|
|
|
|
try {
|
|
let json = await sequence.get(req.params.project, req.params.sequence, req.query);
|
|
const type = req.query.type ?? 2;
|
|
if (type == 2) {
|
|
// Filter out missing raw data
|
|
json = json.filter(el => el.geometryraw);
|
|
} else if (type == 3) {
|
|
// Filter out missing final data
|
|
json = json.filter(el => el.geometryfinal);
|
|
}
|
|
|
|
if (json.length) {
|
|
const data = bundle(json, {type});
|
|
res.status(200).send(Buffer.from(data));
|
|
} else {
|
|
res.status(404).send();
|
|
}
|
|
|
|
next();
|
|
} catch (err) {
|
|
next(err);
|
|
}
|
|
|
|
};
|