Shared state

This commit is contained in:
Andras Schmelczer 2026-03-17 21:08:32 +00:00
parent 53fff3efaa
commit 15fa09430b
25 changed files with 174 additions and 215 deletions

View file

@ -1,5 +1,6 @@
use std::sync::Arc;
use axum::extract::State;
use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
use axum::Json;
@ -7,7 +8,7 @@ use serde::Serialize;
use tracing::warn;
use crate::pocketbase::auth_superuser;
use crate::state::AppState;
use crate::state::{AppState, SharedState};
/// Pricing tiers: (cumulative user cap, price in pence).
const TIERS: &[(u64, u64)] = &[
@ -75,7 +76,8 @@ pub async fn count_licensed_users(state: &AppState) -> anyhow::Result<u64> {
Ok(total)
}
pub async fn get_pricing(state: Arc<AppState>) -> Response {
pub async fn get_pricing(State(shared): State<Arc<SharedState>>) -> Response {
let state = shared.load_state();
let count = match count_licensed_users(&state).await {
Ok(c) => c,
Err(err) => {