Files
Epicnabbo-Catalogus-Updated…/src/app/api/online/route.ts
T
openhands 7f7971f578 fix: resolve all biome lint errors and type issues
- Add file-level biome-ignore for noExplicitAny in prisma-facade.ts
  (intentional any for Prisma API compatibility surface)
- Fix noNonNullAssertion errors in cached-db.ts (redis null-guard fixes)
- Auto-fix formatting + organizeImports across modified files
- 0 tsc errors, 0 biome errors, 583 tests passing
2026-07-31 15:15:15 +02:00

28 lines
733 B
TypeScript

// 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: [] });
}
}