diff options
author | rtkay123 <dev@kanjala.com> | 2025-07-26 18:42:32 +0200 |
---|---|---|
committer | rtkay123 <dev@kanjala.com> | 2025-07-26 18:42:32 +0200 |
commit | 236876f1d0539ac22a3977fd8599933725ad0f90 (patch) | |
tree | 5c216d71ac065621348ce05e7c6c7f7ce81c85d3 /crates/auth/src/state.rs | |
parent | cf77963db4f2b55048d725bd6250a490b0b82d64 (diff) | |
download | sellershut-236876f1d0539ac22a3977fd8599933725ad0f90.tar.bz2 sellershut-236876f1d0539ac22a3977fd8599933725ad0f90.zip |
feat(auth): create user
Diffstat (limited to 'crates/auth/src/state.rs')
-rw-r--r-- | crates/auth/src/state.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/crates/auth/src/state.rs b/crates/auth/src/state.rs index 927823c..5905948 100644 --- a/crates/auth/src/state.rs +++ b/crates/auth/src/state.rs @@ -1,15 +1,20 @@ use std::{ops::Deref, sync::Arc}; -use stack_up::{Configuration, Services}; +use sellershut_core::profile::profile_client::ProfileClient; +use sqlx::PgPool; +use stack_up::Configuration; use tokio::task::JoinHandle; +use tonic::transport::Endpoint; use tower_sessions::{CachingSessionStore, ExpiredDeletion, session_store}; use tower_sessions_moka_store::MokaStore; use tower_sessions_sqlx_store::PostgresStore; +use tracing::error; use crate::{ client::{OauthClient, discord::discord_client}, cnfg::LocalConfig, error::AppError, + server::grpc::interceptor::{Intercepted, MyInterceptor}, }; #[derive(Clone)] @@ -23,12 +28,18 @@ impl Deref for AppHandle { } } +#[derive(Clone)] +pub struct Services { + pub postgres: PgPool, +} + pub struct AppState { pub services: Services, pub local_config: LocalConfig, pub discord_client: OauthClient, pub http_client: reqwest::Client, pub session_store: CachingSessionStore<MokaStore, PostgresStore>, + pub profile_client: ProfileClient<Intercepted>, } impl AppState { @@ -52,6 +63,13 @@ impl AppState { let discord_client = discord_client(&local_config.oauth.discord)?; + let channel = Endpoint::new(local_config.profile_endpoint.to_string())? + .connect() + .await + .inspect_err(|e| error!("could not connect to profile service: {e}"))?; + + let profile_client = ProfileClient::with_interceptor(channel, MyInterceptor); + Ok(( AppHandle(Arc::new(Self { services, @@ -59,6 +77,7 @@ impl AppState { discord_client, http_client: reqwest::Client::new(), session_store: store, + profile_client, })), deletion_task, )) |