refactor(api): split Axum handlers into handler/service/repo modules
Keep the REST contract; move domain logic out of route files so checkout, fulfillment, and identity can be reused across customer, shop, and admin surfaces. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
e457339847
commit
5e866d08f4
@@ -9,11 +9,12 @@ pub struct AppState {
|
||||
|
||||
pub async fn build_state(config: &crate::config::Config) -> anyhow::Result<AppState> {
|
||||
let db = PgPool::connect(&config.database_url).await?;
|
||||
assemble(config.clone(), db).await
|
||||
}
|
||||
|
||||
/// Build state from an already-open pool (migrate + serve share one pool).
|
||||
pub async fn assemble(config: crate::config::Config, db: PgPool) -> anyhow::Result<AppState> {
|
||||
let client = redis::Client::open(config.redis_url.clone())?;
|
||||
let redis = redis::aio::ConnectionManager::new(client).await?;
|
||||
Ok(AppState {
|
||||
db,
|
||||
redis,
|
||||
config: config.clone(),
|
||||
})
|
||||
Ok(AppState { db, redis, config })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user