diff --git a/server/Cargo.toml b/server/Cargo.toml index 4ba4db0..1f74ba2 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -26,3 +26,7 @@ tonic-build = "0.12.3" tonic-reflection = "0.12.3" tracing = "0.1.41" tracing-subscriber = "0.3.19" + +[lib] +name = "server" +path = "src/lib.rs" diff --git a/server/src/lib.rs b/server/src/lib.rs index 9558def..12f578b 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -5,3 +5,6 @@ pub mod adresar; pub mod uctovnictvo; pub mod shared; pub mod table_structure; + +// Re-export run_server from the inner server module: +pub use server::run_server; diff --git a/server/src/main.rs b/server/src/main.rs index e6d4524..e48123e 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -1,20 +1,24 @@ -// src/main.rs +// server/src/main.rs use std::env; use dotenvy::dotenv; -use crate::db; + +// Import from the external library crate (named `server`) +use server::run_server; +use server::db; #[tokio::main] async fn main() -> Result<(), Box> { dotenv().ok(); - // Initialize database + // Initialize database using library module `db` let db_config = db::DatabaseConfig::from_env(); let db_pool = db::create_pool(&db_config).await?; match env::args().nth(1).as_deref() { - Some("server") => server::run_server(db_pool).await?, + Some("server") => run_server(db_pool).await?, _ => println!("Usage: cargo run -- [server|client]"), } Ok(()) } +