Files
web-nuxt/server/utils/mock-scenario.ts
Noel Sabia 233fdbf66c feat: live SSE stage, phone view and presenter control
- proxy Go /api/stream through Nitro; drive /stage, /live, /plan and /forecast from scenario events
- fall back to 5 s polling after SSE failures or heartbeat silence; show Live/Polling/Offline
- authenticate /control and POST /api/scenario in Nitro with server-side control credentials
- add big-screen stage with local QR and a no-login phone recommendation view
- add SSE unit tests and a live smoke test; refresh README/Makefile
2026-11-14 06:59:07 +01:00

25 lines
778 B
TypeScript

import type { ScenarioDefinition, ScenarioState } from '../../shared/types'
import { mockScenario } from './mock-data'
// Mock mode has no Go process, but the presenter controls and the 5 s polling
// fallback should still observe a version change. Nitro keeps this per-process
// state, exactly like the single Go pod keeps its in-memory scenario.
let current: ScenarioState = clone(mockScenario)
function clone<T>(value: T): T {
return JSON.parse(JSON.stringify(value)) as T
}
export function getMockScenario(): ScenarioState {
return clone(current)
}
export function setMockScenario(input: ScenarioDefinition): ScenarioState {
current = {
version: current.version + 1,
scenario: clone(input),
at: new Date().toISOString(),
}
return clone(current)
}