import { NextResponse } from "next/server";
import { eventService } from "@/services/events/event.service";

export async function GET() {
  try {
    const events = await eventService.getAllEvents({
      orderBy: { date: "asc" },
    });

    return NextResponse.json(events);
  } catch (error) {
    console.error("Error fetching events:", error);
    return NextResponse.json(
      { error: "Erreur lors de la récupération des événements" },
      { status: 500 }
    );
  }
}
