import type { APIRoute } from "astro";
import { prisma } from "../lib/prisma";

export const prerender = false;

export const GET: APIRoute = async () => {
  try {
    const count = await prisma.formulario.count();

    return Response.json(
      { success: true, count },
      { headers: { "Cache-Control": "no-store" } }
    );
  } catch (error) {
    console.error("Error en /api/voluntarios/count:", error);
    return Response.json(
      { success: false, message: "Error al obtener el contador de voluntarios" },
      { status: 500 }
    );
  }
};
