- Add nostr-rs-relay service to docker-compose for persistent comments, reactions, and profiles on the dev server - Add one-shot seeder container that auto-populates the relay with test personas, reactions, and comments on first deploy - Proxy WebSocket connections through nginx at /relay so the frontend connects to the relay on the same host (no CORS) - Make relay URL dynamic: reads from VITE_NOSTR_RELAYS in dev, auto-detects /relay proxy path in production Docker builds - Make seed scripts configurable via RELAY_URL and ORIGIN env vars - Add wait-for-relay script for reliable container orchestration - Add "Resume last played" hero banner on My List tab Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
/**
|
|
* Relay pool and relay constants.
|
|
* Extracted into its own module to avoid circular dependencies
|
|
* between nostr.ts and accounts.ts.
|
|
*/
|
|
import { BehaviorSubject } from 'applesauce-core'
|
|
import { RelayPool } from 'applesauce-relay'
|
|
|
|
// Relay pool for all WebSocket connections
|
|
export const pool = new RelayPool()
|
|
|
|
/**
|
|
* Determine app relay URLs at runtime.
|
|
*
|
|
* Priority:
|
|
* 1. VITE_NOSTR_RELAYS env var (set in .env for local dev)
|
|
* 2. Auto-detect: proxy through same host at /relay (Docker / production)
|
|
*/
|
|
function getAppRelays(): string[] {
|
|
const envRelays = import.meta.env.VITE_NOSTR_RELAYS as string | undefined
|
|
if (envRelays) {
|
|
const parsed = envRelays.split(',').map((r: string) => r.trim()).filter(Boolean)
|
|
if (parsed.length > 0) return parsed
|
|
}
|
|
|
|
// Production / Docker: relay is proxied through nginx at /relay
|
|
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'
|
|
return [`${protocol}//${window.location.host}/relay`]
|
|
}
|
|
|
|
// App relays (local dev relay or proxied production relay)
|
|
export const APP_RELAYS = getAppRelays()
|
|
|
|
// Lookup relays for profile metadata
|
|
export const LOOKUP_RELAYS = ['wss://purplepag.es']
|
|
|
|
// Observable relay list for reactive subscriptions
|
|
export const appRelays = new BehaviorSubject<string[]>([...APP_RELAYS])
|