18 lines
743 B
TypeScript
18 lines
743 B
TypeScript
|
|
import { NextResponse, type NextRequest } from 'next/server'
|
||
|
|
import { prisma } from '@/lib/prisma'
|
||
|
|
import { expirePendingPastDeadline } from '@/server/services/finalist-confirmation'
|
||
|
|
|
||
|
|
export async function GET(request: NextRequest): Promise<NextResponse> {
|
||
|
|
const cronSecret = request.headers.get('x-cron-secret')
|
||
|
|
if (!cronSecret || cronSecret !== process.env.CRON_SECRET) {
|
||
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
||
|
|
}
|
||
|
|
try {
|
||
|
|
const result = await expirePendingPastDeadline(prisma)
|
||
|
|
return NextResponse.json({ ok: true, ...result })
|
||
|
|
} catch (error) {
|
||
|
|
console.error('[Cron] finalist-confirmations failed:', error)
|
||
|
|
return NextResponse.json({ error: 'Internal error' }, { status: 500 })
|
||
|
|
}
|
||
|
|
}
|