import { idParamsSchema } from "../../utils/schema";
import { FastifyInstanceType } from "../../utils/types";
import { getFair, getFairs } from "./controller";

export async function fairsRoutes(fastify: FastifyInstanceType) {
  //-------------------------------------------------------------------------------
  fastify.get(
    "",
    {
      preHandler: (req, reply) => fastify.auth(req, reply, false),
    },
    getFairs
  );
  //-------------------------------------------------------------------------------
  fastify.get(
    ":id/",
    {
      preHandler: (req, reply) => fastify.auth(req, reply, false),
      schema: {
        params: idParamsSchema,
      },
    },
    getFair
  );
  //-------------------------------------------------------------------------------
  fastify.log.info("fairs routes registered");
}
