mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 10:27:09 +00:00
- A single get() function is used both to list all available layers, if no layer name is given, or a single layer. - The database no longer holds the actual layer contents, only the path to the layer file(s), so the list() function is now redundant as we return the full payload in every case. - The /gis/layer and /gis/layer/:name endpoints now have the same payload structure.
19 lines
400 B
JavaScript
19 lines
400 B
JavaScript
|
|
const { gis } = require('../../../../../lib/db');
|
|
|
|
module.exports = async function (req, res, next) {
|
|
|
|
try {
|
|
const layers = await gis.project.layer.get(req.params.project, req.params.name);
|
|
if (req.params.name && (!layers || !layers.length)) {
|
|
res.status(404).json({message: "Not found"});
|
|
} else {
|
|
res.status(200).send(layers ?? []);
|
|
}
|
|
next();
|
|
} catch (err) {
|
|
next(err);
|
|
}
|
|
|
|
};
|