feat(server): /svc/status — how F is doing, for the dashboard's monitoring (F9)

What /healthz says (documents, connections, rooms) and what it keeps to
itself: the people in the rooms, the rooms each thread holds, the
process's memory, its uptime, Node's version. Behind the service key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-11 16:27:08 +00:00
co-authored by Claude Opus 5.5
parent 739f8aab3a
commit f351caa824
2 changed files with 34 additions and 1 deletions
+11
View File
@@ -132,6 +132,17 @@ describe('a simulation room on F', () => {
['sim.stop', 'ben'],
]);
expect(server.sims.stats()).toEqual({ rooms: 1, people: 2, threads: [1] });
// What the dashboard's monitoring reads (F9): the same, and the process — only with the service key.
const status = await fetch(`${server.base}/svc/status`, { headers: { 'x-filius-service-key': SERVICE_KEY } });
expect(status.status).toBe(200);
const said = (await status.json()) as Record<string, unknown> & { memory: { rssMb: number; heapUsedMb: number }; uptimeSeconds: number };
expect(said).toMatchObject({ rooms: 1, people: 2, threads: [1], node: process.version });
expect(said.documents).toBeGreaterThanOrEqual(1);
expect(said.connections).toBeGreaterThanOrEqual(0);
expect(said.memory.rssMb).toBeGreaterThan(0);
expect(said.memory.heapUsedMb).toBeGreaterThan(0);
expect(said.uptimeSeconds).toBeGreaterThanOrEqual(0);
expect((await fetch(`${server.base}/svc/status`)).status).toBe(403);
mia.socket.close();
ben.socket.close();
await server.close();