// Public REST API — count of currently-online users. // // `online` is the emulator's string flag "1" / "0" (see User model). Returns // { count: 0 } (never 500) on DB failure. import { apiJson } from "@/lib/api"; import { cached } from "@/lib/cache"; import { prisma } from "@/lib/prisma"; export const dynamic = "force-dynamic"; export async function GET(_req: Request) { try { const count = await cached("online_count", 10_000, () => prisma.user.count({ where: { online: "1" } }), ); return apiJson({ count }); } catch { return apiJson({ count: 0 }); } }