/**
 * @ai-summary Fastify routes for ownership costs API
 */
import { FastifyInstance, FastifyPluginAsync, FastifyPluginOptions } from 'fastify';
import { OwnershipCostsController } from './ownership-costs.controller';

export const ownershipCostsRoutes: FastifyPluginAsync = async (
  fastify: FastifyInstance,
  _opts: FastifyPluginOptions
) => {
  const ctrl = new OwnershipCostsController();
  const requireAuth = fastify.authenticate.bind(fastify);

  fastify.get('/ownership-costs', {
    preHandler: [requireAuth],
    handler: ctrl.list.bind(ctrl)
  });

  fastify.get<{ Params: any }>('/ownership-costs/:id', {
    preHandler: [requireAuth],
    handler: ctrl.get.bind(ctrl)
  });

  fastify.post<{ Body: any }>('/ownership-costs', {
    preHandler: [requireAuth],
    handler: ctrl.create.bind(ctrl)
  });

  fastify.put<{ Params: any; Body: any }>('/ownership-costs/:id', {
    preHandler: [requireAuth],
    handler: ctrl.update.bind(ctrl)
  });

  fastify.delete<{ Params: any }>('/ownership-costs/:id', {
    preHandler: [requireAuth],
    handler: ctrl.remove.bind(ctrl)
  });
};
