api route 구성 1

This commit is contained in:
koreacomp5
2025-10-09 14:18:55 +09:00
parent 296df7b582
commit 0f7c62d731
7 changed files with 191 additions and 1 deletions

View File

@@ -0,0 +1,16 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET(_: Request, context: { params: Promise<{ id: string }> }) {
const { id } = await context.params;
const post = await prisma.post.findUnique({
where: { id },
include: {
board: { select: { id: true, name: true, slug: true } },
},
});
if (!post) return NextResponse.json({ error: "Not found" }, { status: 404 });
return NextResponse.json({ post });
}