
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);
	}

};
