From 137edf2d0dcf01c389e3f34ebd7d51ddddd9e345 Mon Sep 17 00:00:00 2001 From: wallace Date: Tue, 11 Nov 2025 11:41:08 +0900 Subject: [PATCH] =?UTF-8?q?prisma=20=EC=84=B1=EA=B3=B5~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 6 ++++++ app/api/test/route.ts | 30 ++++++++++++++++++++++++++++ app/page.tsx | 44 ++++++++++++++++++++++++++++-------------- app/studydata/page.tsx | 0 prisma.config.ts | 2 ++ prisma/schema.prisma | 22 +++++++++++++++++++++ 6 files changed, 90 insertions(+), 14 deletions(-) create mode 100644 app/api/test/route.ts create mode 100644 app/studydata/page.tsx create mode 100644 prisma/schema.prisma diff --git a/.gitignore b/.gitignore index cd3f340..358fbaa 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,9 @@ next-env.d.ts /lib/generated/prisma /lib/generated/prisma + +/lib/generated/prisma + +/lib/generated/prisma + +/lib/generated/prisma diff --git a/app/api/test/route.ts b/app/api/test/route.ts new file mode 100644 index 0000000..b48bff5 --- /dev/null +++ b/app/api/test/route.ts @@ -0,0 +1,30 @@ +import { PrismaClient } from "@/lib/generated/prisma/client"; +import { NextResponse } from "next/server"; + +const prisma = new PrismaClient(); + +export async function GET() { + try { + const tests = await prisma.test.findMany(); + return NextResponse.json(tests); + } catch (error) { + console.error(error); + return NextResponse.json({ error: "Failed to fetch tests." }, { status: 500 }); + } +} + +export async function POST(req: Request) { + try { + const body = await req.json(); + const { name } = body; + if (!name) { + return NextResponse.json({ error: "Name is required." }, { status: 400 }); + } + const test = await prisma.test.create({ + data: { name }, + }); + return NextResponse.json(test, { status: 201 }); + } catch (error) { + return NextResponse.json({ error: "Failed to create test." }, { status: 500 }); + } +} diff --git a/app/page.tsx b/app/page.tsx index 37b2cc7..8993b7d 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -69,40 +69,56 @@ export default function HomePage() { return (
{/* 헤더 */} -
+
{/* 로고 */} {/* 메뉴 */}
-
+
-
+ +
-
+ +
+
{/* 사용자 메뉴 */} @@ -131,7 +147,7 @@ export default function HomePage() {
{/* 구분선 */} -
+
diff --git a/app/studydata/page.tsx b/app/studydata/page.tsx new file mode 100644 index 0000000..e69de29 diff --git a/prisma.config.ts b/prisma.config.ts index 6b6d3b6..aaf400c 100644 --- a/prisma.config.ts +++ b/prisma.config.ts @@ -1,4 +1,6 @@ import { defineConfig, env } from "prisma/config"; +import { config } from "dotenv"; +config(); export default defineConfig({ schema: "prisma/schema.prisma", diff --git a/prisma/schema.prisma b/prisma/schema.prisma new file mode 100644 index 0000000..d9086a8 --- /dev/null +++ b/prisma/schema.prisma @@ -0,0 +1,22 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? +// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init + +generator client { + provider = "prisma-client" + output = "../lib/generated/prisma" +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} + +model Test { + id String @id @default(uuid()) + name String + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +}