Privacy/PII review-pass van Server Actions, API-routes, debug-paths en Sentry config: ✅ Sentry sendDefaultPii: false in alle drie configs (server/edge/client) ✅ Geen wachtwoord/email/token in console-logs ✅ Pair-id-logs zijn metadata-only (5-min TTL, geen secret) ⚠️ Vier debug-routes hadden geen auth-guard: - /api/debug/realtime-stream — rauwe pg_notify-stream zonder filtering - /api/debug/emit-test-notify — anonieme test-emit op het kanaal - /debug-env — lekt env-var-metadata (hostnames, lengtes, pooled-flag) - /debug-realtime — UI op dezelfde rauwe pg_notify-stream Allemaal gemarkeerd als TIJDELIJK met VERWIJDEREN-comments uit M8. Voor v1 launch: NODE_ENV-guard die in productie 404 retourneert. Lokaal dev blijft alles werken voor debugging. Toekomstige cleanup: kunnen worden verwijderd zodra M8-realtime stabiel draait in productie en niemand ze meer nodig heeft. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
// TIJDELIJKE debug-endpoint. Stuurt een handmatige pg_notify op
|
|
// `scrum4me_changes` zonder een echte UPDATE te doen. Bedoeld om de
|
|
// SSE-pipe te testen los van Prisma/triggers.
|
|
//
|
|
// VERWIJDEREN voor M8 out-of-draft.
|
|
|
|
import { Client } from 'pg'
|
|
|
|
export const runtime = 'nodejs'
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
const CHANNEL = 'scrum4me_changes'
|
|
|
|
export async function POST(request: Request) {
|
|
// Productie-guard: anonieme test-emit op pg_notify is niet voor productie.
|
|
if (process.env.NODE_ENV === 'production') {
|
|
return new Response('Not found', { status: 404 })
|
|
}
|
|
|
|
const directUrl = process.env.DIRECT_URL ?? process.env.DATABASE_URL
|
|
if (!directUrl) {
|
|
return Response.json({ error: 'DIRECT_URL/DATABASE_URL niet gezet' }, { status: 500 })
|
|
}
|
|
|
|
let body: unknown = null
|
|
try {
|
|
body = await request.json()
|
|
} catch {
|
|
// empty body is OK — we vullen defaults in
|
|
}
|
|
|
|
const overrides = (body && typeof body === 'object' ? body : {}) as Record<string, unknown>
|
|
const payload = {
|
|
op: 'U',
|
|
entity: 'task',
|
|
id: `debug-${Date.now()}`,
|
|
story_id: 'debug-story',
|
|
product_id: 'debug-product',
|
|
sprint_id: null,
|
|
assignee_id: null,
|
|
task_status: 'TO_DO',
|
|
task_sort_order: 1,
|
|
task_title: 'manual debug emit',
|
|
changed_fields: ['status'],
|
|
debug: true,
|
|
emitted_at: new Date().toISOString(),
|
|
...overrides,
|
|
}
|
|
|
|
const client = new Client({ connectionString: directUrl })
|
|
try {
|
|
await client.connect()
|
|
// pg_notify met JSON-string als payload — zelfde formaat als de trigger
|
|
await client.query('SELECT pg_notify($1, $2)', [CHANNEL, JSON.stringify(payload)])
|
|
return Response.json({ ok: true, payload })
|
|
} catch (err) {
|
|
return Response.json(
|
|
{ ok: false, error: err instanceof Error ? err.message : String(err) },
|
|
{ status: 500 },
|
|
)
|
|
} finally {
|
|
try { await client.end() } catch {}
|
|
}
|
|
}
|