import type { FastifyInstance } from "fastify"; import { requirePermission } from "../auth.js"; import type { DeviceMonitor } from "../device-monitor.js"; // Unified device-status snapshot for the booth footer. The DeviceMonitor polls all // configured devices (relays/readers/cameras via healthCheck, printers via their // rich readStatus) in the background; this exposes its cache. Live updates ride the // booth WebSocket (kind:"device-status") — this REST route is the initial load / // fallback. Any authenticated role may read (operational, not a setup action). // See wiki/concepts/device-status-monitoring.md, booth-console.md. export async function deviceStatusRoutes( app: FastifyInstance, monitor: DeviceMonitor, ): Promise { const guard = requirePermission("device:read"); app.get("/api/devices/status", { preHandler: guard }, async () => ({ devices: monitor.snapshot(), })); }