feat(api): 공용 카테고리 API 추가 (대분류+소분류 함께 반환)
docs(todo): 헤더 네비 작업 3번(데이터 연동 설계) 완료 표시
This commit is contained in:
18
src/app/api/categories/route.ts
Normal file
18
src/app/api/categories/route.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
// 대분류(BoardCategory)와 소분류(Board)를 함께 반환
|
||||
export async function GET() {
|
||||
const categories = await prisma.boardCategory.findMany({
|
||||
orderBy: [{ sortOrder: "asc" }, { createdAt: "asc" }],
|
||||
include: {
|
||||
boards: {
|
||||
orderBy: [{ sortOrder: "asc" }, { createdAt: "asc" }],
|
||||
select: { id: true, name: true, slug: true, requiresApproval: true, type: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
return NextResponse.json({ categories });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user