REFACTOR(repo): simplify project structure
- Move services/nextjs/ to nextjs/ - Move Dockerfile.prod to Dockerfile at root - Remove deploy/ folder (K8s manifests moved to K3S-HOME/web-apps) - Remove .gitea/ workflows - Update GitHub Actions for new structure - Remove develop branch triggers
This commit is contained in:
84
nextjs/app/api/auth/password/route.ts
Normal file
84
nextjs/app/api/auth/password/route.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { corsHeaders, handleCorsPreFlight } from '@/shared/lib/cors'
|
||||
|
||||
const PASSWORD = '5364'
|
||||
const SESSION_COOKIE_NAME = 'todo-auth-session'
|
||||
|
||||
// OPTIONS - CORS preflight 처리
|
||||
export async function OPTIONS() {
|
||||
return handleCorsPreFlight()
|
||||
}
|
||||
|
||||
// POST - 비밀번호 인증
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const body = await request.json()
|
||||
const { password } = body
|
||||
|
||||
if (!password) {
|
||||
const response = NextResponse.json(
|
||||
{ success: false, error: '비밀번호를 입력해주세요' },
|
||||
{ status: 400 }
|
||||
)
|
||||
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||
response.headers.set(key, value)
|
||||
})
|
||||
return response
|
||||
}
|
||||
|
||||
if (password === PASSWORD) {
|
||||
// 인증 성공 - 세션 쿠키 설정
|
||||
const response = NextResponse.json(
|
||||
{ success: true, message: '인증 성공' },
|
||||
{ status: 200 }
|
||||
)
|
||||
|
||||
// HttpOnly 쿠키로 세션 저장 (보안 강화)
|
||||
response.cookies.set(SESSION_COOKIE_NAME, 'authenticated', {
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === 'production',
|
||||
sameSite: 'lax',
|
||||
maxAge: 60 * 60 * 24, // 24시간
|
||||
path: '/',
|
||||
})
|
||||
|
||||
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||
response.headers.set(key, value)
|
||||
})
|
||||
return response
|
||||
} else {
|
||||
const response = NextResponse.json(
|
||||
{ success: false, error: '비밀번호가 일치하지 않습니다' },
|
||||
{ status: 401 }
|
||||
)
|
||||
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||
response.headers.set(key, value)
|
||||
})
|
||||
return response
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Password auth error:', error)
|
||||
const response = NextResponse.json(
|
||||
{ success: false, error: '서버 오류가 발생했습니다' },
|
||||
{ status: 500 }
|
||||
)
|
||||
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||
response.headers.set(key, value)
|
||||
})
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
// GET - 인증 상태 확인
|
||||
export async function GET(request: NextRequest) {
|
||||
const session = request.cookies.get(SESSION_COOKIE_NAME)?.value
|
||||
|
||||
const response = NextResponse.json(
|
||||
{ success: true, authenticated: session === 'authenticated' },
|
||||
{ status: 200 }
|
||||
)
|
||||
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||
response.headers.set(key, value)
|
||||
})
|
||||
return response
|
||||
}
|
||||
25
nextjs/app/api/health/route.ts
Normal file
25
nextjs/app/api/health/route.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { prisma } from '@/shared/lib/prisma'
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
// 데이터베이스 연결 확인
|
||||
await prisma.$queryRaw`SELECT 1`
|
||||
|
||||
return NextResponse.json({
|
||||
status: 'ok',
|
||||
timestamp: new Date().toISOString(),
|
||||
database: 'connected'
|
||||
})
|
||||
} catch {
|
||||
return NextResponse.json(
|
||||
{
|
||||
status: 'error',
|
||||
timestamp: new Date().toISOString(),
|
||||
error: 'Database connection failed'
|
||||
},
|
||||
{ status: 503 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
79
nextjs/app/api/todos/[id]/route.ts
Normal file
79
nextjs/app/api/todos/[id]/route.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { prisma } from '@/shared/lib/prisma'
|
||||
import { corsHeaders, handleCorsPreFlight } from '@/shared/lib/cors'
|
||||
import type { Prisma } from '@prisma/client'
|
||||
|
||||
// OPTIONS - CORS preflight 처리
|
||||
export async function OPTIONS() {
|
||||
return handleCorsPreFlight()
|
||||
}
|
||||
|
||||
// PUT - TODO 업데이트
|
||||
export async function PUT(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const { id: idParam } = await params
|
||||
const id = parseInt(idParam)
|
||||
const body = await request.json()
|
||||
|
||||
const updateData: Prisma.TodoUpdateInput = {}
|
||||
if (body.title !== undefined) updateData.title = body.title
|
||||
if (body.description !== undefined) updateData.description = body.description
|
||||
if (body.completed !== undefined) updateData.completed = body.completed
|
||||
if (body.priority !== undefined) updateData.priority = body.priority
|
||||
|
||||
const todo = await prisma.todo.update({
|
||||
where: { id },
|
||||
data: updateData,
|
||||
})
|
||||
|
||||
const response = NextResponse.json({ success: true, data: todo })
|
||||
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||
response.headers.set(key, value)
|
||||
})
|
||||
return response
|
||||
} catch (error) {
|
||||
console.error('Error updating todo:', error)
|
||||
const response = NextResponse.json(
|
||||
{ success: false, error: 'Failed to update todo' },
|
||||
{ status: 500 }
|
||||
)
|
||||
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||
response.headers.set(key, value)
|
||||
})
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
// DELETE - TODO 삭제
|
||||
export async function DELETE(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const { id: idParam } = await params
|
||||
const id = parseInt(idParam)
|
||||
await prisma.todo.delete({
|
||||
where: { id },
|
||||
})
|
||||
|
||||
const response = NextResponse.json({ success: true, message: 'Todo deleted' })
|
||||
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||
response.headers.set(key, value)
|
||||
})
|
||||
return response
|
||||
} catch (error) {
|
||||
console.error('Error deleting todo:', error)
|
||||
const response = NextResponse.json(
|
||||
{ success: false, error: 'Failed to delete todo' },
|
||||
{ status: 500 }
|
||||
)
|
||||
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||
response.headers.set(key, value)
|
||||
})
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
65
nextjs/app/api/todos/route.ts
Normal file
65
nextjs/app/api/todos/route.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { prisma } from '@/shared/lib/prisma'
|
||||
import { corsHeaders, handleCorsPreFlight } from '@/shared/lib/cors'
|
||||
|
||||
// OPTIONS - CORS preflight 처리
|
||||
export async function OPTIONS() {
|
||||
return handleCorsPreFlight()
|
||||
}
|
||||
|
||||
// GET - 모든 TODO 가져오기
|
||||
export async function GET() {
|
||||
try {
|
||||
const todos = await prisma.todo.findMany({
|
||||
orderBy: { createdAt: 'desc' },
|
||||
})
|
||||
const response = NextResponse.json({ success: true, data: todos })
|
||||
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||
response.headers.set(key, value)
|
||||
})
|
||||
return response
|
||||
} catch (error) {
|
||||
console.error('Error fetching todos:', error)
|
||||
const response = NextResponse.json(
|
||||
{ success: false, error: 'Failed to fetch todos' },
|
||||
{ status: 500 }
|
||||
)
|
||||
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||
response.headers.set(key, value)
|
||||
})
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
// POST - TODO 생성
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const body = await request.json()
|
||||
|
||||
const todo = await prisma.todo.create({
|
||||
data: {
|
||||
title: body.title,
|
||||
description: body.description || null,
|
||||
completed: body.completed || false,
|
||||
priority: body.priority || 'medium',
|
||||
},
|
||||
})
|
||||
|
||||
const response = NextResponse.json({ success: true, data: todo }, { status: 201 })
|
||||
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||
response.headers.set(key, value)
|
||||
})
|
||||
return response
|
||||
} catch (error) {
|
||||
console.error('Error creating todo:', error)
|
||||
const response = NextResponse.json(
|
||||
{ success: false, error: 'Failed to create todo' },
|
||||
{ status: 500 }
|
||||
)
|
||||
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||
response.headers.set(key, value)
|
||||
})
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
BIN
nextjs/app/favicon.ico
Normal file
BIN
nextjs/app/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 263 KiB |
172
nextjs/app/globals.css
Normal file
172
nextjs/app/globals.css
Normal file
@@ -0,0 +1,172 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
--background: 0 0% 100%;
|
||||
--foreground: 222.2 84% 4.9%;
|
||||
--card: 0 0% 100%;
|
||||
--card-foreground: 222.2 84% 4.9%;
|
||||
--popover: 0 0% 100%;
|
||||
--popover-foreground: 222.2 84% 4.9%;
|
||||
--primary: 221.2 83.2% 53.3%;
|
||||
--primary-foreground: 210 40% 98%;
|
||||
--secondary: 210 40% 96%;
|
||||
--secondary-foreground: 222.2 84% 4.9%;
|
||||
--muted: 210 40% 96%;
|
||||
--muted-foreground: 215.4 16.3% 46.9%;
|
||||
--accent: 210 40% 96%;
|
||||
--accent-foreground: 222.2 84% 4.9%;
|
||||
--destructive: 0 84.2% 60.2%;
|
||||
--destructive-foreground: 210 40% 98%;
|
||||
--border: 214.3 31.8% 91.4%;
|
||||
--input: 214.3 31.8% 91.4%;
|
||||
--ring: 221.2 83.2% 53.3%;
|
||||
--radius: 0.5rem;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: 222.2 84% 4.9%;
|
||||
--foreground: 210 40% 98%;
|
||||
--card: 222.2 84% 4.9%;
|
||||
--card-foreground: 210 40% 98%;
|
||||
--popover: 222.2 84% 4.9%;
|
||||
--popover-foreground: 210 40% 98%;
|
||||
--primary: 217.2 91.2% 59.8%;
|
||||
--primary-foreground: 222.2 84% 4.9%;
|
||||
--secondary: 217.2 32.6% 17.5%;
|
||||
--secondary-foreground: 210 40% 98%;
|
||||
--muted: 217.2 32.6% 17.5%;
|
||||
--muted-foreground: 215 20.2% 65.1%;
|
||||
--accent: 217.2 32.6% 17.5%;
|
||||
--accent-foreground: 210 40% 98%;
|
||||
--destructive: 0 62.8% 30.6%;
|
||||
--destructive-foreground: 210 40% 98%;
|
||||
--border: 217.2 32.6% 17.5%;
|
||||
--input: 217.2 32.6% 17.5%;
|
||||
--ring: 224.3 76.3% 94.1%;
|
||||
}
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
@apply border-gray-200;
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
--radius-sm: calc(var(--radius) - 4px);
|
||||
--radius-md: calc(var(--radius) - 2px);
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: calc(var(--radius) + 4px);
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--color-card: var(--card);
|
||||
--color-card-foreground: var(--card-foreground);
|
||||
--color-popover: var(--popover);
|
||||
--color-popover-foreground: var(--popover-foreground);
|
||||
--color-primary: var(--primary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-destructive: var(--destructive);
|
||||
--color-border: var(--border);
|
||||
--color-input: var(--input);
|
||||
--color-ring: var(--ring);
|
||||
--color-chart-1: var(--chart-1);
|
||||
--color-chart-2: var(--chart-2);
|
||||
--color-chart-3: var(--chart-3);
|
||||
--color-chart-4: var(--chart-4);
|
||||
--color-chart-5: var(--chart-5);
|
||||
--color-sidebar: var(--sidebar);
|
||||
--color-sidebar-foreground: var(--sidebar-foreground);
|
||||
--color-sidebar-primary: var(--sidebar-primary);
|
||||
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
||||
--color-sidebar-accent: var(--sidebar-accent);
|
||||
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||
--color-sidebar-border: var(--sidebar-border);
|
||||
--color-sidebar-ring: var(--sidebar-ring);
|
||||
}
|
||||
:root {
|
||||
--radius: 0.625rem;
|
||||
--background: oklch(1 0 0);
|
||||
--foreground: oklch(0.145 0 0);
|
||||
--card: oklch(1 0 0);
|
||||
--card-foreground: oklch(0.145 0 0);
|
||||
--popover: oklch(1 0 0);
|
||||
--popover-foreground: oklch(0.145 0 0);
|
||||
--primary: oklch(0.205 0 0);
|
||||
--primary-foreground: oklch(0.985 0 0);
|
||||
--secondary: oklch(0.97 0 0);
|
||||
--secondary-foreground: oklch(0.205 0 0);
|
||||
--muted: oklch(0.97 0 0);
|
||||
--muted-foreground: oklch(0.556 0 0);
|
||||
--accent: oklch(0.97 0 0);
|
||||
--accent-foreground: oklch(0.205 0 0);
|
||||
--destructive: oklch(0.577 0.245 27.325);
|
||||
--border: oklch(0.922 0 0);
|
||||
--input: oklch(0.922 0 0);
|
||||
--ring: oklch(0.708 0 0);
|
||||
--chart-1: oklch(0.646 0.222 41.116);
|
||||
--chart-2: oklch(0.6 0.118 184.704);
|
||||
--chart-3: oklch(0.398 0.07 227.392);
|
||||
--chart-4: oklch(0.828 0.189 84.429);
|
||||
--chart-5: oklch(0.769 0.188 70.08);
|
||||
--sidebar: oklch(0.985 0 0);
|
||||
--sidebar-foreground: oklch(0.145 0 0);
|
||||
--sidebar-primary: oklch(0.205 0 0);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.97 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.205 0 0);
|
||||
--sidebar-border: oklch(0.922 0 0);
|
||||
--sidebar-ring: oklch(0.708 0 0);
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: oklch(0.145 0 0);
|
||||
--foreground: oklch(0.985 0 0);
|
||||
--card: oklch(0.205 0 0);
|
||||
--card-foreground: oklch(0.985 0 0);
|
||||
--popover: oklch(0.205 0 0);
|
||||
--popover-foreground: oklch(0.985 0 0);
|
||||
--primary: oklch(0.922 0 0);
|
||||
--primary-foreground: oklch(0.205 0 0);
|
||||
--secondary: oklch(0.269 0 0);
|
||||
--secondary-foreground: oklch(0.985 0 0);
|
||||
--muted: oklch(0.269 0 0);
|
||||
--muted-foreground: oklch(0.708 0 0);
|
||||
--accent: oklch(0.269 0 0);
|
||||
--accent-foreground: oklch(0.985 0 0);
|
||||
--destructive: oklch(0.704 0.191 22.216);
|
||||
--border: oklch(1 0 0 / 10%);
|
||||
--input: oklch(1 0 0 / 15%);
|
||||
--ring: oklch(0.556 0 0);
|
||||
--chart-1: oklch(0.488 0.243 264.376);
|
||||
--chart-2: oklch(0.696 0.17 162.48);
|
||||
--chart-3: oklch(0.769 0.188 70.08);
|
||||
--chart-4: oklch(0.627 0.265 303.9);
|
||||
--chart-5: oklch(0.645 0.246 16.439);
|
||||
--sidebar: oklch(0.205 0 0);
|
||||
--sidebar-foreground: oklch(0.985 0 0);
|
||||
--sidebar-primary: oklch(0.488 0.243 264.376);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.269 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.985 0 0);
|
||||
--sidebar-border: oklch(1 0 0 / 10%);
|
||||
--sidebar-ring: oklch(0.556 0 0);
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
@apply border-border outline-ring/50;
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
||||
34
nextjs/app/layout.tsx
Normal file
34
nextjs/app/layout.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Geist, Geist_Mono } from "next/font/google";
|
||||
import "./globals.css";
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
subsets: ["latin"],
|
||||
});
|
||||
|
||||
const geistMono = Geist_Mono({
|
||||
variable: "--font-geist-mono",
|
||||
subsets: ["latin"],
|
||||
});
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Todo App - 할 일 관리",
|
||||
description: "효율적으로 할 일을 관리하고 생산성을 높여보세요",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body
|
||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||
>
|
||||
{children}
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
11
nextjs/app/page.tsx
Normal file
11
nextjs/app/page.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { TodoApp } from '@/src/widgets/todo-app'
|
||||
import PasswordModal from '@/src/features/password-auth/ui/PasswordModal'
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<PasswordModal>
|
||||
<TodoApp />
|
||||
</PasswordModal>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user