
const { project } = require('../../../lib/db');

module.exports = async function (req, res, next) {

	try {
		const accessibleProjects = project.organisations.orgFilter(
			req.user?.organisations,
			await project.get(),
			'read'
		);
		res.status(200).send(accessibleProjects);
		next();
	} catch (err) {
		next(err);
	}

};
