diff --git a/CLAUDE.md b/CLAUDE.md index ffa67d0..21cd5d4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1114,6 +1114,40 @@ pnpm test:coverage - Functions: 50% - Branches: 65% +## Scheduled Cron Jobs (Vercel) + +Automatische Hintergrund-Jobs via Vercel Cron (`vercel.json`): + +| Endpoint | Schedule | Beschreibung | +|----------|----------|--------------| +| `/api/cron/community-sync` | `*/15 * * * *` (alle 15 Min) | Synchronisiert Kommentare von YouTube, Facebook, Instagram | +| `/api/cron/token-refresh` | `0 6,18 * * *` (6:00 + 18:00 UTC) | Erneuert ablaufende OAuth-Tokens automatisch | + +**Authentifizierung:** +Alle Cron-Endpoints erfordern `Authorization: Bearer $CRON_SECRET` Header. + +**Manueller Trigger:** +```bash +# Community Sync manuell auslösen +curl -X POST "https://your-domain/api/cron/community-sync" \ + -H "Authorization: Bearer $CRON_SECRET" \ + -H "Content-Type: application/json" \ + -d '{"platforms": ["youtube", "facebook"]}' + +# Token Refresh manuell auslösen (Dry-Run) +curl "https://your-domain/api/cron/token-refresh?dryRun=true" \ + -H "Authorization: Bearer $CRON_SECRET" + +# Token Refresh Status prüfen +curl -I "https://your-domain/api/cron/token-refresh" \ + -H "Authorization: Bearer $CRON_SECRET" +``` + +**Monitoring:** +- HEAD-Requests geben Status-Header zurück (`X-Sync-Running`, `X-Last-Run`, etc.) +- Bei laufendem Job: HTTP 423 (Locked) +- Fehlerhafte Tokens werden als Benachrichtigungen in `yt-notifications` gespeichert + ## CI/CD Pipeline GitHub Actions Workflows in `.github/workflows/`: diff --git a/vercel.json b/vercel.json index d410113..058eeb5 100644 --- a/vercel.json +++ b/vercel.json @@ -4,6 +4,10 @@ { "path": "/api/cron/community-sync", "schedule": "*/15 * * * *" + }, + { + "path": "/api/cron/token-refresh", + "schedule": "0 6,18 * * *" } ] }