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 createXmlMulti from './controllers/createXmlMulti.js';
import readDir from './controllers/readDir.js';
import fileStat from './controllers/fileStat.js';
import fileSearch from './controllers/fileSearch.js';
import clearTiles from './controllers/clearTiles.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-create-xml/:id?', adminParams, createXmlMulti);
  app.get('/gis-files', adminParams, readDir);
  app.get('/gis-file-info', adminParams, fileStat);
  app.get('/gis-file-search', adminParams, fileSearch);
  app.get('/gis-clear-rtile/:id', adminParams, clearTiles);
}
