deploy first
This commit is contained in:
22
app/api/admin/handle/cpv/route.ts
Normal file
22
app/api/admin/handle/cpv/route.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
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 {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user