Files
ef_front/app/api/admin/handle/cpv/route.ts

23 lines
748 B
TypeScript
Raw Permalink Normal View History

2025-09-10 04:31:53 +00:00
import { NextResponse } from 'next/server'
import { PrismaClient } from '@/app/generated/prisma'
export async function POST(request: Request) {
const prisma = new PrismaClient()
try {
const body = await request.json().catch(() => ({})) as any
const id = String(body?.id || '')
const costPerView = Number(body?.costPerView)
if (!id || !Number.isFinite(costPerView)) {
return NextResponse.json({ error: 'invalid payload' }, { status: 400 })
}
await prisma.handle.update({ where: { id }, data: { costPerView } })
return NextResponse.json({ ok: true })
} catch (e) {
return NextResponse.json({ error: 'update failed' }, { status: 500 })
} finally {
try { await prisma.$disconnect() } catch {}
}
}