// src/server/features/reference_books/index.ts
// Reference books feature plugin - registers all reference books routes

import { FastifyPluginAsync } from 'fastify';
import fp from 'fastify-plugin';
import externalAccessRoutes from './external_access.routes';
import contractorsRoutes from './contractors.routes';
import localITRoutes from './local_it.routes';
import inventoryRoutes from './inventory.routes';

const referenceBooksPlugin: FastifyPluginAsync = async (fastify, opts) => {
  // Register all reference books routes
  // Note: blacklist routes are registered separately via blacklistPlugin in app.ts
  
  // Register contractors routes with explicit prefix
  await fastify.register(contractorsRoutes, { prefix: '/api' });
  
  // Register other reference books routes
  await fastify.register(externalAccessRoutes, { prefix: '/api' });
  await fastify.register(localITRoutes, { prefix: '/api' });
  await fastify.register(inventoryRoutes, { prefix: '/api' });
};

export default fp(referenceBooksPlugin, {
  name: 'reference-books-plugin',
});
