From 7245b3e3e91fcad8615efc612357a296018a19bb Mon Sep 17 00:00:00 2001 From: mota Date: Mon, 13 Oct 2025 08:08:02 +0900 Subject: [PATCH] =?UTF-8?q?feat(api):=20=EA=B3=B5=EC=9A=A9=20=EC=B9=B4?= =?UTF-8?q?=ED=85=8C=EA=B3=A0=EB=A6=AC=20API=20=EC=B6=94=EA=B0=80=20(?= =?UTF-8?q?=EB=8C=80=EB=B6=84=EB=A5=98+=EC=86=8C=EB=B6=84=EB=A5=98=20?= =?UTF-8?q?=ED=95=A8=EA=BB=98=20=EB=B0=98=ED=99=98)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit docs(todo): 헤더 네비 작업 3번(데이터 연동 설계) 완료 표시 --- .cursor/.prompt/header_navigation작업.md | 4 ++-- src/app/api/categories/route.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 src/app/api/categories/route.ts diff --git a/.cursor/.prompt/header_navigation작업.md b/.cursor/.prompt/header_navigation작업.md index c1e1205..32f4471 100644 --- a/.cursor/.prompt/header_navigation작업.md +++ b/.cursor/.prompt/header_navigation작업.md @@ -8,8 +8,8 @@ - [x] 헤더 컨테이너/레이아웃 골격 생성(`src/app/components/AppHeader.tsx` 확장) 3) 데이터 연동 설계 -- [ ] 대분류 소스 결정: `GET /api/boards?category=...` 또는 카테고리 전용 API 사용 -- [ ] 소분류(보드) 매핑 규칙 정의(현재 시드 트리 기준) +- [x] 대분류 소스 결정: `GET /api/categories` 사용(대분류+소분류 동시 제공) +- [x] 소분류(보드) 매핑 규칙 정의(현재 시드 트리 기준) 4) 대분류 네비 구현 - [ ] 상단에 대분류 탭 렌더링(정렬/활성 상태 반영) diff --git a/src/app/api/categories/route.ts b/src/app/api/categories/route.ts new file mode 100644 index 0000000..55fe64e --- /dev/null +++ b/src/app/api/categories/route.ts @@ -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 }); +} + +