first commit

This commit is contained in:
2025-09-07 22:57:43 +00:00
commit 3bd542adbf
122 changed files with 45056 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import { NextResponse } from 'next/server';
import { PrismaClient } from '@/app/generated/prisma';
const prisma = new PrismaClient();
export async function GET() {
try {
const row = await prisma.costPerView.findUnique({ where: { id: 1 } });
return NextResponse.json({ value: row?.costPerView ?? null });
} catch (e) {
console.error('GET /api/cost_per_view 오류:', e);
return NextResponse.json({ error: '조회 실패' }, { status: 500 });
}
}
export async function POST(request: Request) {
try {
const body = await request.json();
const valueRaw = body?.value;
const value = typeof valueRaw === 'string' ? parseFloat(valueRaw) : valueRaw;
if (typeof value !== 'number' || Number.isNaN(value)) {
return NextResponse.json({ error: '유효한 숫자 값을 제공하세요' }, { status: 400 });
}
const saved = await prisma.costPerView.upsert({
where: { id: 1 },
update: { costPerView: value },
create: { id: 1, costPerView: value },
});
return NextResponse.json({ ok: true, value: saved.costPerView });
} catch (e) {
console.error('POST /api/cost_per_view 오류:', e);
return NextResponse.json({ error: '저장 실패' }, { status: 500 });
}
}