diff options
| author | Adam Soltys <[email protected]> | 2026-10-01 06:55:14 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-01 06:55:14 -0700 |
| commit | 5d441ebbce6066c3636168ec5332ae9c2bdb8607 (patch) | |
| tree | 7e70c783fc0be40eccb09af7499db586c5410526 /dev.js | |
| parent | 981ff1c7f89b27ff3d7c2957e211365baff0a359 (diff) | |
| download | coinosv3-5d441ebbce6066c3636168ec5332ae9c2bdb8607.tar.gz coinosv3-5d441ebbce6066c3636168ec5332ae9c2bdb8607.zip | |
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.
Diffstat (limited to 'dev.js')
| -rw-r--r-- | dev.js | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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; |
