import catalogPermissions from './controllers/catalog.permissions.js';
import catalogPermissionsEdit from './controllers/catalog.permissions.edit.js';
import gisCatalog from './controllers/gis.catalog.js';

export default async function route(fastify) {
  if (!fastify.hasRoute({ method: 'GET', url: '/api/catalog' })) {
    console.log('\x1b[34m%s\x1b[0m', 'add catalog from gis');
    fastify.get('/catalog', { policy: 'L2' }, gisCatalog);
  }
  if (!fastify.hasRoute({ method: 'GET', url: '/api/catalog-permissions/:uid' })) {
    console.log('\x1b[34m%s\x1b[0m', 'add catalog-permissions from gis');
    fastify.get('/catalog-permissions/:uid', { policy: 'L2' }, catalogPermissions);
  }
  if (!fastify.hasRoute({ method: 'POST', url: '/api/catalog-permissions/:uid' })) {
    console.log('\x1b[34m%s\x1b[0m', 'add catalog-permissions-edit from gis');
    fastify.post('/catalog-permissions/:uid', { policy: 'L2' }, catalogPermissionsEdit);
  }
}
