Files
erika/app/admin/backend/page.tsx
T

47 lines
1.3 KiB
TypeScript

import { AdminShell } from "@/components/admin-shell";
import { readdirSync } from "fs";
import { join } from "path";
import { BackendClient } from "./client";
export const dynamic = "force-dynamic";
export default async function BackendPage() {
// Auto-discover platform files from lib/followers/
const dir = join(process.cwd(), "lib", "followers");
const platforms = readdirSync(dir)
.filter((f) => f.endsWith(".ts") && f !== "index.ts")
.map((f) => f.replace(".ts", ""));
// Read current cached counts from Redis
let counts: Record<string, number | null> = {};
try {
const { getRedisClient } = await import("@/lib/redis");
const redis = await getRedisClient();
const cached = await redis.get("erika:follower_counts");
if (cached) {
counts = JSON.parse(cached);
}
} catch {
// Redis unavailable
}
const platformData = platforms.map((p) => ({
name: p,
cachedCount: counts[p] ?? null,
}));
return (
<AdminShell>
<div className="p-6 space-y-6 max-w-6xl mx-auto w-full">
<div>
<h1 className="text-3xl font-bold tracking-tight">Backend</h1>
<p className="text-muted-foreground mt-1">
Follower API connections and cache management
</p>
</div>
<BackendClient platforms={platformData} />
</div>
</AdminShell>
);
}