Skip to content

Commit

Permalink
feat(site): add AuthDomainService to site-server
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbchron committed Dec 8, 2024
1 parent 46cd637 commit 158a854
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/prime-domain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions crates/site-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 22 additions & 2 deletions crates/site-server/src/main.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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<Box<dyn PrimeDomainService>> =
Arc::new(Box::new(PrimeDomainServiceCanonical::new(photo_repo)));
let auth_domain_service: Arc<Box<dyn AuthDomainService>> =
Arc::new(Box::new(AuthDomainServiceCanonical::new(user_repo)));

Ok(Self {
prime_domain_service,
auth_domain_service,
})
}
}
Expand Down

0 comments on commit 158a854

Please sign in to comment.