diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-04 10:42:18 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-04 10:42:18 +0000 |
| commit | 9394657613014891ff91db6cd0a01b21bb257053 (patch) | |
| tree | e59ff64c5463039e4304928b3b24377e3e438822 /src/main.rs | |
| parent | 52bad9954cdddf55ab749fd0c6387edbc766632f (diff) | |
feat: implement NIP-01 compliant Nostr relay
- WebSocket-based relay using tokio-tungstenite
- Full NIP-01 protocol support (EVENT, REQ, CLOSE)
- Event validation (signature and ID)
- In-memory event storage
- Filter support (IDs, authors, kinds, since/until)
- Configuration via environment variables
- Nix flake for reproducible builds
- Test automation script
All 6 NIP-01 smoke tests passing (100%)
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..7da4c73 --- /dev/null +++ b/src/main.rs | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | use anyhow::Result; | ||
| 2 | use tracing::{info, Level}; | ||
| 3 | use tracing_subscriber::FmtSubscriber; | ||
| 4 | |||
| 5 | mod config; | ||
| 6 | mod nostr; | ||
| 7 | mod storage; | ||
| 8 | |||
| 9 | use config::Config; | ||
| 10 | |||
| 11 | #[tokio::main] | ||
| 12 | async fn main() -> Result<()> { | ||
| 13 | // Initialize tracing | ||
| 14 | let subscriber = FmtSubscriber::builder() | ||
| 15 | .with_max_level(Level::DEBUG) | ||
| 16 | .finish(); | ||
| 17 | tracing::subscriber::set_global_default(subscriber)?; | ||
| 18 | |||
| 19 | info!("Starting ngit-grasp..."); | ||
| 20 | |||
| 21 | // Load configuration | ||
| 22 | let config = Config::from_env()?; | ||
| 23 | info!("Configuration loaded: {}", config.bind_address); | ||
| 24 | |||
| 25 | // Initialize storage | ||
| 26 | let storage = storage::Storage::new(&config)?; | ||
| 27 | info!("Storage initialized at: {}", config.relay_data_path); | ||
| 28 | |||
| 29 | // Start Nostr relay | ||
| 30 | let relay = nostr::relay::RelayServer::new(config.clone(), storage)?; | ||
| 31 | |||
| 32 | info!("Starting Nostr relay on {}", config.bind_address); | ||
| 33 | relay.run().await?; | ||
| 34 | |||
| 35 | Ok(()) | ||
| 36 | } | ||