Refactor AppState and update database connection handling; integrate SettingsService

This commit is contained in:
GW_MC
2025-12-02 16:56:01 +08:00
parent fae951c902
commit f71cf370cd
2 changed files with 31 additions and 12 deletions

View File

@@ -3,20 +3,22 @@ use std::sync::Arc;
use axum::{Extension, Router};
use migration::sea_orm::DatabaseConnection;
use crate::middlewares;
use crate::{middlewares, services::settings::SettingsStore};
#[derive(Clone)]
pub struct AppState {
// TODO: remove dead_code allowances when fields are used
#[allow(dead_code)]
pub database_connection: DatabaseConnection,
pub database_connection: Arc<DatabaseConnection>,
// TODO: remove dead_code allowances when fields are used
#[allow(dead_code)]
pub service: Arc<AppService>,
}
pub type ServiceState<T: ?Sized + Send + Sync> = Arc<T>;
pub struct AppService {
//
pub settings: ServiceState<dyn SettingsStore>,
}
pub fn get_root_router(state: impl Into<Arc<AppState>>) -> Router {