import fp from 'fastify-plugin';

import config from './config.js';

config.prefix = config.prefix || '/api';

async function plugin(fastify, opts = config) {
  // const prefix = config.prefix || '/api';

  fastify.register(import('./server/helpers/index.js'), opts);
  // fastify.register(import('@opengis/fastify-auth'), config);

  fastify.register(import('./server/plugins/cron.js'), opts); // cron / scheduler
  fastify.register(import('./server/plugins/hook.js'), opts); // data / template hooks
  // fastify.register(import('./server/plugins/access/index.mjs'), opts); // check access / analogue of policy

  // API
  // fastify.register(import('./server/routes/properties/index.mjs'), opts);
  fastify.register(import('./server/routes/calendar/index.mjs'), opts);
  fastify.register(import('./server/routes/notifications/index.mjs'), opts);
  // fastify.register(import('./server/routes/templates/index.mjs'), opts);
  // fastify.register(import('./server/routes/menu/index.mjs'), opts);
  // fastify.register(import('./server/routes/data/index.mjs'), opts);
  // fastify.register(import('./server/routes/user/index.mjs'), opts);
  // fastify.register(import('./server/routes/widget/index.mjs'), opts); // moved to core
  // fastify.register(import('./server/routes/access/index.mjs'), opts); // moved to core
  // fastify.register(import('./server/routes/report/index.mjs'), opts);
  // fastify.register(import('./server/routes/print/index.mjs'), opts);
  // fastify.register(import('./server/routes/util/index.mjs'), opts); // moved to core
}
export default fp(plugin)