import uploadRaster from './controllers/uploadRaster.js';
import createXml from './controllers/createXml.js';
import rtile from './controllers/rtile.js';
import rasterInfo from './controllers/rasterInfo.js';
import mapnikStat from './controllers/mapnikStat.js';
import mapnikLogger from './controllers/mapnikLogger.js';
import checkCarto from './controllers/checkCarto.js';
import createXmlMulti from './controllers/createXmlMulti.js';

const publicParams = { config: { policy: 'L0' }, package: 'gis' }; // L0 === public
const adminParams = { config: { policy: 'L1', role: 'admin' }, package: 'gis' };
const params = { config: { policy: 'L1' }, package: 'gis' }; // L1 === authorized only

export default async function route(app) {
  app.get('/gis-upload-raster/:id', params, uploadRaster);
  app.get('/gis-xml/:id', publicParams, createXml);
  app.get('/gis-rtile/:id/:z/:y/:x', publicParams, rtile);
  app.get('/gis-raster/:id', publicParams, rasterInfo);
  app.get('/gis-stat/:period?', adminParams, mapnikStat);
  app.get('/gis-logger/*', adminParams, mapnikLogger);
  app.get('/gis-css/:id', params, checkCarto);
  app.get('/gis-create-xml/:id?', adminParams, createXmlMulti);
}
