pub mod agent_client; pub mod auth; pub mod nginx; pub mod server_state; pub mod settings; use std::sync::Arc; use ::agent_client::apis::configuration::Configuration; use crate::{ configs::ProgramSettings, routes::{self, AuthState}, services::{ auth::{ authentication::{AuthenticationServiceImpl, strategies::password::PasswordStrategy}, user::{UserService, UserServiceImpl}, }, nginx::NginxService, server_state::{ServerStateService, ServerStateStore}, settings::{SettingsService, SettingsStore}, }, }; pub type ServiceState = Arc; pub struct AppService { pub settings: ServiceState, pub auth_state: AuthState, pub user: ServiceState, pub server_state: ServiceState, #[allow(dead_code)] pub nginx: ServiceState, #[allow(dead_code)] pub agent_client: ServiceState, } pub fn get_app_service( db_connection: &Arc, settings: &ProgramSettings, ) -> AppService { AppService { server_state: Arc::new(ServerStateService::new(db_connection.clone())), settings: Arc::new(SettingsService::new(db_connection.clone())), auth_state: routes::AuthState { strategy: routes::AuthStrategy { password: Arc::new(PasswordStrategy::new(db_connection.clone())), }, authentication: Arc::new(AuthenticationServiceImpl::new( settings.auth.jwt_secret.clone(), )), }, user: Arc::new(UserServiceImpl::new(db_connection.clone())), nginx: Arc::new(NginxService::new(db_connection.clone())), agent_client: Arc::new(agent_client::AgentService::new(Configuration::from( settings.agent.clone(), ))), } }