import { NextResponse } from "next/server";
import { db } from "@/lib/db";

/** Public API: list published conferences. */
export async function GET() {
  const conferences = await db.conference.findMany({
    where: { status: { in: ["PUBLISHED", "LIVE", "COMPLETED"] } },
    orderBy: { startAt: "asc" },
    select: {
      id: true, name: true, slug: true, tagline: true, type: true, status: true,
      startAt: true, endAt: true, timezone: true, city: true, country: true, venueName: true,
      org: { select: { name: true, slug: true } },
      _count: { select: { sessions: true, speakers: true } },
    },
  });
  return NextResponse.json({ data: conferences });
}
