A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
feat: sent state via sse upon connection
Christian Fei8fade6f19f65
diff --git a/lib/server.js b/lib/server.jsindex 2a5e9c9..ab5675b 100644--- a/lib/server.js+++ b/lib/server.js@@ -30,7 +30,10 @@ export function createServer ({repo, state = {}, connections = []} = {}) {try {const url = new URL(req.url, `http://${req.headers.host}`)- if (req.headers.accept && req.headers.accept.indexOf('text/event-stream') >= 0) return handleSSE(res, connections)+ if (req.headers.accept && req.headers.accept.indexOf('text/event-stream') >= 0) {+ handleSSE(res, connections)+ return broadcastSSE(JSON.stringify({type: 'state', state}), connections)+ }if (url.pathname.startsWith('/api/')) return apiHandler(req, res, repo, connections, state)