Skip to content

WebSocket live event streaming at /rpc/live #6

@theonlyhennygod

Description

@theonlyhennygod

v0.0.5 — WebSocket Live Stream

Problem

Self-hosted nodes sync via polling (every 30s). For real-time feeds, nodes need WebSocket event streaming.

Acceptance Criteria

  • WS /rpc/live accepts WebSocket upgrade with node API key auth
  • New events broadcast to all connected WebSocket clients in real-time
  • Events include a backfill message on connect with recent events
  • Client can subscribe to filters (kinds, pubkeys)
  • Ping/pong heartbeat keeps connection alive
  • Reconnection with cursor-based catchup
  • E2E test: connect WS, create event on central, receive it via WS

Files to create/modify

  • apps/api/src/routes/rpc.ts (replace stub with real WS handler)
  • apps/api/src/lib/event-bus.ts (NEW — pub/sub for live events)
  • apps/api/src/lib/sync/client.ts (add WS listener option)
  • apps/api/scripts/test-websocket-live.ts (NEW)

Test

bun run test:websocket-live

Version bump

All package.json files: 0.0.4 to 0.0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions