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

// 대분류(BoardCategory)와 소분류(Board)를 함께 반환
export async function GET() {
  const categories = await prisma.boardCategory.findMany({
    where: { status: "active" },
    orderBy: [{ sortOrder: "asc" }, { createdAt: "asc" }],
    include: {
      boards: {
        where: { status: "active" },
        orderBy: [{ sortOrder: "asc" }, { createdAt: "asc" }],
        select: { id: true, name: true, slug: true },
      },
    },
  });
  return NextResponse.json({ categories });
}


