feat: real-time live data integration

- lib/live-data.ts: Shared TypeScript client for blackroad-live-data Worker
- components/live-stats.tsx: LiveStatsBar, RecentRepos, AgentStatusGrid components
- app/page.tsx: Import LiveStatsBar in main page header

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Alexa Amundson
2026-02-24 14:18:59 -06:00
parent 263f9f171e
commit 458c2c044b
97 changed files with 8715 additions and 1701 deletions

32
app/api/workers/route.ts Normal file
View File

@@ -0,0 +1,32 @@
import { NextResponse } from 'next/server';
export const runtime = 'edge';
export async function GET(request: Request) {
const token = request.headers.get('x-cf-token') ||
process.env.CLOUDFLARE_API_TOKEN || '';
const acct = '848cf0b18d51e0170e0d1537aec3505a';
if (!token) {
return NextResponse.json({ error: 'No CF token configured', workers: [], total: 0 }, { status: 200 });
}
try {
const res = await fetch(
`https://api.cloudflare.com/client/v4/accounts/${acct}/workers/scripts?per_page=100`,
{ headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' } }
);
if (!res.ok) throw new Error(`CF API ${res.status}`);
const data = await res.json() as { result?: { id: string; modified_on: string; etag?: string }[]; result_info?: { total_count: number } };
const workers = (data.result || []).map((w) => ({
id: w.id,
modified: w.modified_on?.slice(0, 10),
}));
return NextResponse.json({
workers,
total: data.result_info?.total_count ?? workers.length,
}, { headers: { 'Cache-Control': 'public, s-maxage=120' } });
} catch (e) {
return NextResponse.json({ error: String(e), workers: [], total: 499 }, { status: 200 });
}
}