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
This commit is contained in:
1 parent
7181562e0f
commit
233fdbf66c
24 files changed
+2757
-49
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import QRCode from 'qrcode'
|
||||
|
||||
/**
|
||||
* Generate the /stage QR code locally. No third-party QR image service is
|
||||
* called at runtime, so the big screen keeps working without internet access.
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const query = getQuery(event)
|
||||
const text = typeof query.text === 'string' ? query.text.trim() : ''
|
||||
if (!text) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'text is required' })
|
||||
}
|
||||
if (text.length > 1024) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'text is too long for a QR code' })
|
||||
}
|
||||
|
||||
let svg: string
|
||||
try {
|
||||
svg = await QRCode.toString(text, {
|
||||
type: 'svg',
|
||||
margin: 1,
|
||||
width: 320,
|
||||
errorCorrectionLevel: 'M',
|
||||
color: { dark: '#0f172a', light: '#ffffff' },
|
||||
})
|
||||
} catch {
|
||||
throw createError({ statusCode: 400, statusMessage: 'could not encode text as a QR code' })
|
||||
}
|
||||
|
||||
setResponseHeaders(event, {
|
||||
'content-type': 'image/svg+xml; charset=utf-8',
|
||||
'cache-control': 'public, max-age=300',
|
||||
})
|
||||
return svg
|
||||
})
|
||||
Reference in new issue
Block a user