Files
QR-master/src/app/(main)/api/cron/social-milestones/route.ts

18 lines
802 B
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { detectSocialMilestones } from '@/lib/social-milestones-server';
import { getSocialMilestoneThresholds } from '@/lib/social-milestones';
export const dynamic = 'force-dynamic';
function isAuthorized(request: NextRequest) {
const secret = process.env.CRON_SECRET;
return Boolean(secret) && request.headers.get('authorization') === `Bearer ${secret}`;
}
// Detection only: this route never contacts customers or an external network.
export async function GET(request: NextRequest) {
if (!isAuthorized(request)) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
const detected = await detectSocialMilestones();
return NextResponse.json({ ok: true, detected, thresholds: getSocialMilestoneThresholds() });
}