에디터 MVP 골격 및 프로젝트 저장/로드 기능 구현

This commit is contained in:
2025-11-18 06:04:39 +09:00
commit 4b00e9a3f9
26 changed files with 11179 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import { NextResponse } from "next/server";
import { PrismaClient } from "@/generated/prisma/client";
const prisma = new PrismaClient();
interface Params {
params: {
slug: string;
};
}
export async function GET(_request: Request, { params }: Params) {
const { slug } = params;
const project = await prisma.project.findUnique({
where: { slug },
});
if (!project) {
return NextResponse.json({ message: "프로젝트를 찾을 수 없습니다." }, { status: 404 });
}
return NextResponse.json(project, { status: 200 });
}
+30
View File
@@ -0,0 +1,30 @@
import { NextResponse } from "next/server";
import { PrismaClient } from "@/generated/prisma/client";
const prisma = new PrismaClient();
export async function POST(request: Request) {
const body = await request.json();
const { title, slug, contentJson } = body;
if (!title || !slug || typeof title !== "string" || typeof slug !== "string") {
return NextResponse.json({ message: "title과 slug는 필수입니다." }, { status: 400 });
}
try {
const project = await prisma.project.create({
data: {
title,
slug,
contentJson,
},
});
return NextResponse.json(project, { status: 201 });
} catch (error: any) {
return NextResponse.json(
{ message: "프로젝트 생성 중 오류가 발생했습니다.", error: error?.message },
{ status: 500 },
);
}
}