From 3556e416125a2ade57a9be8e672b32642f914de6 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Sat, 5 Apr 2025 01:24:38 -0500 Subject: [PATCH] server: flatten remaining files --- migration-tool/src/lldap.rs | 10 ++-- server/src/{infra => }/auth_service.rs | 2 +- server/src/{infra => }/cli.rs | 2 +- server/src/{infra => }/configuration.rs | 2 +- server/src/{infra => }/database_string.rs | 0 server/src/{infra => }/db_cleaner.rs | 0 server/src/{infra => }/graphql_server.rs | 2 +- server/src/{infra => }/healthcheck.rs | 2 +- server/src/{infra => }/jwt_sql_tables.rs | 0 server/src/{infra => }/ldap_server.rs | 2 +- server/src/{infra => }/logging.rs | 2 +- server/src/{infra => }/mail.rs | 2 +- server/src/main.rs | 51 +++++++++++-------- server/src/{infra => }/mod.rs | 0 server/src/{infra => }/schema.rs | 0 .../{infra => }/sql_tcp_backend_handler.rs | 2 +- server/src/{infra => }/tcp_backend_handler.rs | 0 server/src/{infra => }/tcp_server.rs | 4 +- 18 files changed, 47 insertions(+), 36 deletions(-) rename server/src/{infra => }/auth_service.rs (99%) rename server/src/{infra => }/cli.rs (99%) rename server/src/{infra => }/configuration.rs (99%) rename server/src/{infra => }/database_string.rs (100%) rename server/src/{infra => }/db_cleaner.rs (100%) rename server/src/{infra => }/graphql_server.rs (98%) rename server/src/{infra => }/healthcheck.rs (98%) rename server/src/{infra => }/jwt_sql_tables.rs (100%) rename server/src/{infra => }/ldap_server.rs (99%) rename server/src/{infra => }/logging.rs (97%) rename server/src/{infra => }/mail.rs (98%) rename server/src/{infra => }/mod.rs (100%) rename server/src/{infra => }/schema.rs (100%) rename server/src/{infra => }/sql_tcp_backend_handler.rs (99%) rename server/src/{infra => }/tcp_backend_handler.rs (100%) rename server/src/{infra => }/tcp_server.rs (98%) diff --git a/migration-tool/src/lldap.rs b/migration-tool/src/lldap.rs index 4320d59..300e339 100644 --- a/migration-tool/src/lldap.rs +++ b/migration-tool/src/lldap.rs @@ -88,7 +88,7 @@ impl User { query_path = "queries/create_user.graphql", response_derives = "Debug", variables_derives = "Debug,Clone", - custom_scalars_module = "crate::infra::graphql" + custom_scalars_module = "crate::graphql" )] struct CreateUser; @@ -100,7 +100,7 @@ pub type CreateUserInput = create_user::CreateUserInput; query_path = "queries/create_group.graphql", response_derives = "Debug", variables_derives = "Debug,Clone", - custom_scalars_module = "crate::infra::graphql" + custom_scalars_module = "crate::graphql" )] struct CreateGroup; @@ -109,7 +109,7 @@ struct CreateGroup; schema_path = "../schema.graphql", query_path = "queries/list_users.graphql", response_derives = "Debug", - custom_scalars_module = "crate::infra::graphql" + custom_scalars_module = "crate::graphql" )] struct ListUsers; @@ -118,7 +118,7 @@ struct ListUsers; schema_path = "../schema.graphql", query_path = "queries/list_groups.graphql", response_derives = "Debug", - custom_scalars_module = "crate::infra::graphql" + custom_scalars_module = "crate::graphql" )] struct ListGroups; @@ -364,7 +364,7 @@ pub fn get_lldap_groups(graphql_client: &GraphQLClient) -> Result Result Result { "Restart the server without --force-update-private-key or --force-ldap-user-pass-reset to continue." ); } - let server_builder = infra::ldap_server::build_ldap_server( + let server_builder = ldap_server::build_ldap_server( &config, backend_handler.clone(), actix_server::Server::build(), ) .context("while binding the LDAP server")?; - let server_builder = - infra::tcp_server::build_tcp_server(&config, backend_handler, server_builder) - .await - .context("while binding the TCP server")?; + let server_builder = tcp_server::build_tcp_server(&config, backend_handler, server_builder) + .await + .context("while binding the TCP server")?; // Run every hour. let scheduler = Scheduler::new("0 0 * * * * *", sql_pool); scheduler.start(); @@ -212,8 +223,8 @@ async fn set_up_server(config: Configuration) -> Result { async fn run_server_command(opts: RunOpts) -> Result<()> { debug!("CLI: {:#?}", &opts); - let config = infra::configuration::init(opts)?; - infra::logging::init(&config)?; + let config = configuration::init(opts)?; + logging::init(&config)?; let server = set_up_server(config).await?.workers(1); @@ -222,8 +233,8 @@ async fn run_server_command(opts: RunOpts) -> Result<()> { async fn send_test_email_command(opts: TestEmailOpts) -> Result<()> { let to = opts.to.parse()?; - let config = infra::configuration::init(opts)?; - infra::logging::init(&config)?; + let config = configuration::init(opts)?; + logging::init(&config)?; mail::send_test_email(to, &config.smtp_options) .await @@ -232,8 +243,8 @@ async fn send_test_email_command(opts: TestEmailOpts) -> Result<()> { async fn run_healthcheck(opts: RunOpts) -> Result<()> { debug!("CLI: {:#?}", &opts); - let config = infra::configuration::init(opts)?; - infra::logging::init(&config)?; + let config = configuration::init(opts)?; + logging::init(&config)?; info!("Starting healthchecks"); @@ -263,8 +274,8 @@ async fn run_healthcheck(opts: RunOpts) -> Result<()> { async fn create_schema_command(opts: RunOpts) -> Result<()> { debug!("CLI: {:#?}", &opts); - let config = infra::configuration::init(opts)?; - infra::logging::init(&config)?; + let config = configuration::init(opts)?; + logging::init(&config)?; setup_sql_tables(&config.database_url).await?; info!("Schema created successfully."); Ok(()) @@ -272,7 +283,7 @@ async fn create_schema_command(opts: RunOpts) -> Result<()> { #[actix::main] async fn main() -> Result<()> { - let cli_opts = infra::cli::init(); + let cli_opts = cli::init(); match cli_opts.command { Command::ExportGraphQLSchema(opts) => { lldap_graphql_server::api::export_schema(opts.output_file) diff --git a/server/src/infra/mod.rs b/server/src/mod.rs similarity index 100% rename from server/src/infra/mod.rs rename to server/src/mod.rs diff --git a/server/src/infra/schema.rs b/server/src/schema.rs similarity index 100% rename from server/src/infra/schema.rs rename to server/src/schema.rs diff --git a/server/src/infra/sql_tcp_backend_handler.rs b/server/src/sql_tcp_backend_handler.rs similarity index 99% rename from server/src/infra/sql_tcp_backend_handler.rs rename to server/src/sql_tcp_backend_handler.rs index 33a7ff7..923e156 100644 --- a/server/src/infra/sql_tcp_backend_handler.rs +++ b/server/src/sql_tcp_backend_handler.rs @@ -1,4 +1,4 @@ -use crate::infra::tcp_backend_handler::TcpBackendHandler; +use crate::tcp_backend_handler::TcpBackendHandler; use async_trait::async_trait; use chrono::NaiveDateTime; use lldap_domain::types::UserId; diff --git a/server/src/infra/tcp_backend_handler.rs b/server/src/tcp_backend_handler.rs similarity index 100% rename from server/src/infra/tcp_backend_handler.rs rename to server/src/tcp_backend_handler.rs diff --git a/server/src/infra/tcp_server.rs b/server/src/tcp_server.rs similarity index 98% rename from server/src/infra/tcp_server.rs rename to server/src/tcp_server.rs index 8259ad7..b88eeed 100644 --- a/server/src/infra/tcp_server.rs +++ b/server/src/tcp_server.rs @@ -1,4 +1,4 @@ -use crate::infra::{ +use crate::{ auth_service, configuration::{Configuration, MailOptions}, logging::CustomRootSpanBuilder, @@ -145,7 +145,7 @@ fn http_config( .service( web::scope("/api") .wrap(auth_service::CookieToHeaderTranslatorFactory) - .configure(crate::infra::graphql_server::configure_endpoint::), + .configure(crate::graphql_server::configure_endpoint::), ) .service( web::resource("/pkg/lldap_app_bg.wasm.gz")