diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-19 11:55:32 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-19 15:43:29 +0000 |
| commit | fa065ad128882755f2a988d6203b59a2ab5e38ff (patch) | |
| tree | e8326de70a6e6ea56b5bf4250e0a00a3cda4afed /src/main.rs | |
| parent | 98c6fa4bfa897ff0b8f9c95ea698d4d065b5e9f3 (diff) | |
add landing page and nostr-relay-builder relay on same port
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs index 7da4c73..38a3b95 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -3,8 +3,8 @@ use tracing::{info, Level}; | |||
| 3 | use tracing_subscriber::FmtSubscriber; | 3 | use tracing_subscriber::FmtSubscriber; |
| 4 | 4 | ||
| 5 | mod config; | 5 | mod config; |
| 6 | mod http; | ||
| 6 | mod nostr; | 7 | mod nostr; |
| 7 | mod storage; | ||
| 8 | 8 | ||
| 9 | use config::Config; | 9 | use config::Config; |
| 10 | 10 | ||
| @@ -16,21 +16,23 @@ async fn main() -> Result<()> { | |||
| 16 | .finish(); | 16 | .finish(); |
| 17 | tracing::subscriber::set_global_default(subscriber)?; | 17 | tracing::subscriber::set_global_default(subscriber)?; |
| 18 | 18 | ||
| 19 | info!("Starting ngit-grasp..."); | 19 | info!("Starting ngit-grasp with nostr-relay-builder..."); |
| 20 | 20 | ||
| 21 | // Load configuration | 21 | // Load configuration |
| 22 | let config = Config::from_env()?; | 22 | let config = Config::from_env()?; |
| 23 | info!("Configuration loaded: {}", config.bind_address); | 23 | info!("Configuration loaded: {}", config.bind_address); |
| 24 | 24 | ||
| 25 | // Initialize storage | 25 | // Create Nostr relay with NIP-34 validation |
| 26 | let storage = storage::Storage::new(&config)?; | 26 | if let Ok(relay) = nostr::builder::create_relay(&config) { |
| 27 | info!("Storage initialized at: {}", config.relay_data_path); | 27 | info!( |
| 28 | 28 | "Relay created with NIP-34 validation for domain: {}", | |
| 29 | // Start Nostr relay | 29 | config.domain |
| 30 | let relay = nostr::relay::RelayServer::new(config.clone(), storage)?; | 30 | ); |
| 31 | 31 | ||
| 32 | info!("Starting Nostr relay on {}", config.bind_address); | 32 | // Start HTTP server with integrated relay |
| 33 | relay.run().await?; | 33 | info!("Starting HTTP server on {}", config.bind_address); |
| 34 | http::run_server(config, relay).await?; | ||
| 35 | } | ||
| 34 | 36 | ||
| 35 | Ok(()) | 37 | Ok(()) |
| 36 | } | 38 | } |