1mod auth_config;
4mod password_config;
5pub use password_config::{HashConcurrency, PasswordSettings};
6mod client_ip;
7mod config;
8pub use client_ip::{ClientIpResolver, ClientIpSettings, ClientIpStrategy};
9mod jobs_config;
10mod mail_config;
11pub use auth_config::{AuthSettings, AuthThrottleLimit, AuthThrottleSettings, SameSite};
12pub use jobs_config::JobsSettings;
13pub use mail_config::{MailSecret, MailSettings, SmtpSettings};
14mod error;
15mod event_error;
16mod events;
17mod services;
18mod storage_config;
19pub use event_error::{EventError, EventRejection, EventResult};
20pub use events::{Event, EventBus, EventContext, EventFuture, Events};
21pub use services::{Service, Services};
22pub use storage_config::StorageSettings;
23
24pub use config::{
25 ApiSettings, AppConfig, AppSettings, DatabaseSettings, HttpSettings, ServerSettings,
26};
27pub use error::{ApiErrorResponse, AppError, ErrorKind, Result, ValidationErrors};
28use std::sync::Arc;
29
30#[derive(Clone, Debug)]
32pub struct AppContext {
33 pub config: Arc<AppConfig>,
35 pub db: sea_orm::DatabaseConnection,
37}
38
39#[derive(Clone, Debug)]
41pub struct Context(pub AppContext);
42
43impl axum::extract::FromRequestParts<AppContext> for Context {
44 type Rejection = std::convert::Infallible;
45
46 async fn from_request_parts(
47 _parts: &mut axum::http::request::Parts,
48 state: &AppContext,
49 ) -> std::result::Result<Self, Self::Rejection> {
50 Ok(Self(state.clone()))
51 }
52}