Files
portal/src/server/mod.rs
T

36 lines
1.2 KiB
Rust
Raw Normal View History

#![cfg(feature = "ssr")]
pub mod oidc;
use arc_swap::ArcSwap;
use axum::extract::FromRef;
use leptos::prelude::LeptosOptions;
use std::collections::HashMap;
use std::sync::Arc;
use crate::content::Question;
#[derive(Clone)]
pub struct AppState {
pub leptos_options: LeptosOptions,
pub nats: async_nats::Client,
/// JetStream context - source of every NATS KV bucket this app
/// reads/writes (applicants, and whatever a `ResourceSpec` names).
pub jetstream: async_nats::jetstream::Context,
/// Swapped out wholesale on a `content::CONTENT_RELOAD_SUBJECT`
/// message (see `content::watch_for_reload`) - readers never hold
/// a lock, just an atomic pointer load, so a reload never blocks or
/// is blocked by an in-flight request.
pub questions: Arc<ArcSwap<HashMap<String, Question>>>,
pub oidc: Arc<oidc::Oidc>,
/// `None` when `GARAGE_*` env vars aren't set - uploads are the one
/// optional feature, everything else works without Garage.
pub garage: Option<crate::upload::Garage>,
}
impl FromRef<AppState> for LeptosOptions {
fn from_ref(state: &AppState) -> Self {
state.leptos_options.clone()
}
}