From 83876eae868bd1e4fb6b9a823a6e8173919f290d Mon Sep 17 00:00:00 2001 From: bndw Date: Fri, 13 Feb 2026 18:26:53 -0800 Subject: feat: add Connect (gRPC over HTTP/JSON) support Connect integration: - Buf Connect codegen added to buf.gen.yaml - Connect handler wraps gRPC server - Serves on same port as WebSocket (:8080) - HTTP/2 with h2c for cleartext HTTP/2 Now serving THREE protocols: 1. gRPC (native) on :50051 - binary, high performance 2. Connect on :8080/nostr.v1.NostrRelay/* - HTTP/JSON, browser compatible 3. WebSocket on :8080/ - Nostr standard protocol All three protocols share: - Same storage layer - Same subscription manager - Same validation logic Browser-friendly! Call gRPC methods with fetch() or curl. --- README.md | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 8fd35c5..35e697c 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,10 @@ make build-all # Build both ``` The relay will start: -- **gRPC** on `:50051` -- **WebSocket** (Nostr) on `:8080` +- **gRPC** (native) on `:50051` +- **HTTP** server on `:8080`: + - **Connect** (gRPC over HTTP/JSON) at `/nostr.v1.NostrRelay/*` + - **WebSocket** (Nostr protocol) at `/` ### Test with Client @@ -64,6 +66,16 @@ nak req -k 1 --limit 10 ws://localhost:8080 echo '{"kind":1,"content":"hello","tags":[]}' | nak event --sec | nak publish ws://localhost:8080 ``` +**With Connect (HTTP/JSON):** +```bash +# Call gRPC methods over HTTP with JSON +curl -X POST http://localhost:8080/nostr.v1.NostrRelay/PublishEvent \ + -H "Content-Type: application/json" \ + -d '{"event": {...}}' + +# Works from browsers, curl, fetch(), etc. +``` + ## gRPC API See [proto/nostr/v1/nostr.proto](proto/nostr/v1/nostr.proto) for the full API. @@ -82,13 +94,16 @@ See [proto/nostr/v1/nostr.proto](proto/nostr/v1/nostr.proto) for the full API. **Phase 1: Complete** ✅ - ✅ SQLite storage with binary-first design - ✅ Event validation (ID, signature) -- ✅ gRPC publish/query API +- ✅ **Triple protocol support:** + - **gRPC** (native binary protocol) + - **Connect** (gRPC over HTTP/JSON - browser compatible!) + - **WebSocket** (NIP-01 - standard Nostr protocol) - ✅ Subscribe/streaming (real-time event delivery) - ✅ Subscription management (filter matching, fan-out) -- ✅ **WebSocket server (NIP-01) - standard Nostr clients work!** **Compatible with:** -- Any gRPC client (custom or generated) +- Any gRPC client (Go, Python, JS, etc.) +- Any HTTP client (curl, fetch, browsers) - Any Nostr client (Damus, Amethyst, Snort, Iris, Gossip, etc.) - nak CLI for testing -- cgit v1.2.3