api route 구성 1
This commit is contained in:
16
src/app/api/posts/[id]/route.ts
Normal file
16
src/app/api/posts/[id]/route.ts
Normal 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 });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user