diff --git a/Cargo.lock b/Cargo.lock index 4607422..328a9d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3067,6 +3067,7 @@ dependencies = [ name = "site-server" version = "0.1.0" dependencies = [ + "auth-domain", "axum 0.7.9", "leptos", "leptos_axum", diff --git a/crates/prime-domain/src/lib.rs b/crates/prime-domain/src/lib.rs index 2547f67..feb3ac0 100644 --- a/crates/prime-domain/src/lib.rs +++ b/crates/prime-domain/src/lib.rs @@ -8,6 +8,7 @@ use std::sync::Arc; pub use hex; use hex::Hexagonal; use miette::Result; +pub use models; use models::{Photo, PhotoRecordId}; pub use repos; use repos::FetchModelError; diff --git a/crates/site-server/Cargo.toml b/crates/site-server/Cargo.toml index 08852f7..b754764 100644 --- a/crates/site-server/Cargo.toml +++ b/crates/site-server/Cargo.toml @@ -8,12 +8,13 @@ edition = "2021" [dependencies] site-app = { path = "../site-app", default-features = false, features = ["ssr"] } +prime-domain = { path = "../prime-domain" } +auth-domain = { path = "../auth-domain" } + leptos = { workspace = true, features = [ "ssr", "tracing" ]} leptos_axum.workspace = true leptos_router.workspace = true -prime-domain = { path = "../prime-domain" } - axum.workspace = true tokio.workspace = true tower.workspace = true diff --git a/crates/site-server/src/main.rs b/crates/site-server/src/main.rs index 2f7d882..8a6f9eb 100644 --- a/crates/site-server/src/main.rs +++ b/crates/site-server/src/main.rs @@ -1,18 +1,24 @@ use std::{sync::Arc, time::Duration}; +use auth_domain::{ + AuthDomainService, AuthDomainServiceCanonical, DynAuthDomainService, +}; use axum::{extract::FromRef, Router}; use leptos::prelude::*; use leptos_axum::{generate_route_list, LeptosRoutes}; use miette::Result; use prime_domain::{ - hex::retryable::Retryable, DynPrimeDomainService, PrimeDomainService, - PrimeDomainServiceCanonical, + hex::retryable::Retryable, + models::{User, UserCreateRequest}, + repos::CreateModelError, + DynPrimeDomainService, PrimeDomainService, PrimeDomainServiceCanonical, }; use site_app::*; #[derive(Clone, FromRef)] struct AppState { prime_domain_service: DynPrimeDomainService, + auth_domain_service: DynAuthDomainService, } impl AppState { @@ -28,12 +34,26 @@ impl AppState { let photo_repo = prime_domain::repos::BaseModelRepository::new(kv_db_adapter.clone()); + let user_repo: Arc< + Box< + dyn prime_domain::repos::ModelRepository< + Model = User, + ModelCreateRequest = UserCreateRequest, + CreateError = CreateModelError, + >, + >, + > = Arc::new(Box::new(prime_domain::repos::BaseModelRepository::new( + kv_db_adapter.clone(), + ))); let prime_domain_service: Arc> = Arc::new(Box::new(PrimeDomainServiceCanonical::new(photo_repo))); + let auth_domain_service: Arc> = + Arc::new(Box::new(AuthDomainServiceCanonical::new(user_repo))); Ok(Self { prime_domain_service, + auth_domain_service, }) } }