From 5d441ebbce6066c3636168ec5332ae9c2bdb8607 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 1 Oct 2026 06:55:14 -0700 Subject: Serve a shared snapshot for the public feed Build the default Popular feed once on the server and let browsers verify and paint its signed events before slow media finishes. Keep custom relays, pagination, filtering, and relay fallback on their existing paths.\n\nAdd stale-while-refresh persistence, service-worker bypass, development integration, and unit/browser coverage. --- dev.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'dev.js') diff --git a/dev.js b/dev.js index 347ef41..feb315b 100644 --- a/dev.js +++ b/dev.js @@ -6,6 +6,11 @@ // localhost or from a phone over the LAN/Tailscale — no per-device config, no // CORS. HTTP backends by path prefix; WebSocket backends by exact path. +import { startFeedCache } from './feed/service.js'; +import { snapshotResponse } from './feed/cache.js'; + +const publicFeedCache = await startFeedCache(); + import { buildHtml, buildJsQr, buildNip46, buildVerifyWorker } from './build.js'; const port = Number(process.env.PORT || 5173); @@ -23,6 +28,7 @@ Bun.serve({ try { const url = new URL(req.url); const path = url.pathname; + if (path === '/api/feed') return snapshotResponse(publicFeedCache, req); // WebSocket proxies (Fulcrum electrum, SP-indexer push) — upgrade + relay. if (WS_PROXY[path]) { if (server.upgrade(req, { data: { target: WS_PROXY[path] } })) return; -- cgit v1.2.3