// Public REST API — list of currently-online users (username + look only). // // `online` is stored by the emulator as the string "1" / "0" (see User model in // prisma/schema.prisma). Capped at 100 rows. Returns empty data (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 users = await cached("online_users", 10_000, async () => prisma.user.findMany({ where: { online: "1" }, select: { username: true, look: true }, take: 100, }), ); return apiJson({ users }); } catch { return apiJson({ users: [] }); } }