Files
adminandClaude Sonnet 4.6 25f923f530 feat(db): phase 4 group 1 — lib/ settings + notifications to Drizzle
Convert lib/settings.ts, lib/notifications/{in-app,email,capa-escalation,
effectiveness-recheck}.ts from Supabase PostgREST to Drizzle asAdmin queries.
Drop supabase arg from all call sites in app/api/ and cron routes. Rewrite
notification unit tests to mock @/lib/db/with-user instead of SupabaseClient.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 16:37:51 +08:00

20 lines
812 B
TypeScript

export const dynamic = 'force-dynamic'
import { timingSafeEqual } from 'crypto'
import { NextRequest, NextResponse } from 'next/server'
import { sendEffectivenessRecheckNotifications } from '@/lib/notifications/effectiveness-recheck'
export async function GET(request: NextRequest) {
const auth = request.headers.get('authorization') ?? ''
const expected = `Bearer ${process.env.CRON_SECRET ?? ''}`
const authBuf = Buffer.from(auth, 'utf8')
const expectedBuf = Buffer.from(expected, 'utf8')
const valid = authBuf.length === expectedBuf.length && timingSafeEqual(authBuf, expectedBuf)
if (!valid) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
}
const { notified } = await sendEffectivenessRecheckNotifications()
return NextResponse.json({ ok: true, notified })
}