Parallel server-side fetches via Promise.allSettled voor Docker, Caddy, systemd, Git en Audit. Iedere widget toont geaggregeerde status en refresht elke 30s client-side onafhankelijk van de andere widgets. - lib/agent-fetch.ts: gedeelde client-side streaming helper - app/api/audit/latest/route.ts: GET endpoint voor AuditWidget refresh - app/_components/DockerWidget.tsx: running/total containers - app/_components/CaddyWidget.tsx: soonest cert expiry in dagen - app/_components/SystemdWidget.tsx: healthy/total units (of niet geconfigureerd) - app/_components/GitWidget.tsx: dirty repo count (of niet geconfigureerd) - app/_components/AuditWidget.tsx: laatste FlowRun status + relatief tijdstip - app/page.tsx: vervangt SECTIONS-grid, doet parallel fetches, rendert widgets Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
20 lines
629 B
TypeScript
20 lines
629 B
TypeScript
import { NextResponse } from 'next/server'
|
|
import { getCurrentUser } from '@/lib/session'
|
|
import { prisma } from '@/lib/prisma'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
export async function GET() {
|
|
const user = await getCurrentUser()
|
|
if (!user) return NextResponse.json({ error: 'unauthorized' }, { status: 401 })
|
|
|
|
const run = await prisma.flowRun.findFirst({
|
|
where: { user_id: user.id },
|
|
orderBy: { started_at: 'desc' },
|
|
select: { id: true, flow_key: true, status: true, started_at: true },
|
|
})
|
|
|
|
return NextResponse.json({
|
|
run: run ? { ...run, started_at: run.started_at.toISOString() } : null,
|
|
})
|
|
}
|