From 9dd994324948670f1da03baeab620cc51cef877a Mon Sep 17 00:00:00 2001 From: geoffsee <> Date: Tue, 27 May 2025 12:53:35 -0400 Subject: [PATCH] Refactor configuration and main runtime setup. Renamed `AppConfig` to `Runtime` and updated method names for clarity, replacing `new` with `configure`. Adjusted `main.rs` to use the revised `Runtime` struct and method, simplifying server initialization and aligning terminology. --- src/config.rs | 6 +++--- src/main.rs | 15 +++++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/config.rs b/src/config.rs index f15912e..b9f59a2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,10 +1,10 @@ -pub struct AppConfig { +pub struct Runtime { pub env_vars: Vec, } -impl AppConfig { - pub fn new() -> Self { +impl Runtime { + pub fn configure() -> Self { // automatic configuration between local/docker environments match dotenv::dotenv() { Ok(_) => tracing::debug!("Loaded .env file successfully"), diff --git a/src/main.rs b/src/main.rs index 5b93f74..f40fd62 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ -// src/main.rs -use crate::config::AppConfig; +use crate::config::{Runtime}; use crate::routes::create_router; use crate::setup::init_logging; @@ -13,18 +12,14 @@ mod utils; #[tokio::main] async fn main() { - // Initialize logging init_logging(); - // init server configuration - let _ = AppConfig::new(); + Runtime::configure(); - // Create router with all routes - let app = create_router(); + let router = create_router(); - // Start core let addr = "0.0.0.0:3006"; - tracing::info!("Attempting to bind core to {}", addr); + tracing::info!("Attempting to bind server to {}", addr); let listener = match tokio::net::TcpListener::bind(addr).await { Ok(l) => { @@ -38,5 +33,5 @@ async fn main() { }; tracing::info!("Server starting on {}", listener.local_addr().unwrap()); - axum::serve(listener, app.into_make_service()).await.unwrap(); + axum::serve(listener, router.into_make_service()).await.unwrap(); }