diff options
| author | bndw <ben@bdw.to> | 2026-02-13 18:26:53 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-02-13 18:26:53 -0800 |
| commit | 83876eae868bd1e4fb6b9a823a6e8173919f290d (patch) | |
| tree | f754bcb8b10337db34f6f36ba3d094e53c1bb808 /README.md | |
| parent | 3481c3273f8764bd0a0ab51183dc57f592fb616c (diff) | |
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.
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 25 |
1 files changed, 20 insertions, 5 deletions
| @@ -28,8 +28,10 @@ make build-all # Build both | |||
| 28 | ``` | 28 | ``` |
| 29 | 29 | ||
| 30 | The relay will start: | 30 | The relay will start: |
| 31 | - **gRPC** on `:50051` | 31 | - **gRPC** (native) on `:50051` |
| 32 | - **WebSocket** (Nostr) on `:8080` | 32 | - **HTTP** server on `:8080`: |
| 33 | - **Connect** (gRPC over HTTP/JSON) at `/nostr.v1.NostrRelay/*` | ||
| 34 | - **WebSocket** (Nostr protocol) at `/` | ||
| 33 | 35 | ||
| 34 | ### Test with Client | 36 | ### Test with Client |
| 35 | 37 | ||
| @@ -64,6 +66,16 @@ nak req -k 1 --limit 10 ws://localhost:8080 | |||
| 64 | echo '{"kind":1,"content":"hello","tags":[]}' | nak event --sec <nsec> | nak publish ws://localhost:8080 | 66 | echo '{"kind":1,"content":"hello","tags":[]}' | nak event --sec <nsec> | nak publish ws://localhost:8080 |
| 65 | ``` | 67 | ``` |
| 66 | 68 | ||
| 69 | **With Connect (HTTP/JSON):** | ||
| 70 | ```bash | ||
| 71 | # Call gRPC methods over HTTP with JSON | ||
| 72 | curl -X POST http://localhost:8080/nostr.v1.NostrRelay/PublishEvent \ | ||
| 73 | -H "Content-Type: application/json" \ | ||
| 74 | -d '{"event": {...}}' | ||
| 75 | |||
| 76 | # Works from browsers, curl, fetch(), etc. | ||
| 77 | ``` | ||
| 78 | |||
| 67 | ## gRPC API | 79 | ## gRPC API |
| 68 | 80 | ||
| 69 | See [proto/nostr/v1/nostr.proto](proto/nostr/v1/nostr.proto) for the full API. | 81 | 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. | |||
| 82 | **Phase 1: Complete** ✅ | 94 | **Phase 1: Complete** ✅ |
| 83 | - ✅ SQLite storage with binary-first design | 95 | - ✅ SQLite storage with binary-first design |
| 84 | - ✅ Event validation (ID, signature) | 96 | - ✅ Event validation (ID, signature) |
| 85 | - ✅ gRPC publish/query API | 97 | - ✅ **Triple protocol support:** |
| 98 | - **gRPC** (native binary protocol) | ||
| 99 | - **Connect** (gRPC over HTTP/JSON - browser compatible!) | ||
| 100 | - **WebSocket** (NIP-01 - standard Nostr protocol) | ||
| 86 | - ✅ Subscribe/streaming (real-time event delivery) | 101 | - ✅ Subscribe/streaming (real-time event delivery) |
| 87 | - ✅ Subscription management (filter matching, fan-out) | 102 | - ✅ Subscription management (filter matching, fan-out) |
| 88 | - ✅ **WebSocket server (NIP-01) - standard Nostr clients work!** | ||
| 89 | 103 | ||
| 90 | **Compatible with:** | 104 | **Compatible with:** |
| 91 | - Any gRPC client (custom or generated) | 105 | - Any gRPC client (Go, Python, JS, etc.) |
| 106 | - Any HTTP client (curl, fetch, browsers) | ||
| 92 | - Any Nostr client (Damus, Amethyst, Snort, Iris, Gossip, etc.) | 107 | - Any Nostr client (Damus, Amethyst, Snort, Iris, Gossip, etc.) |
| 93 | - nak CLI for testing | 108 | - nak CLI for testing |
| 94 | 109 | ||
