//! Standalone runner for the frida order API.
//!
//! ```text
//! FRIDA_BIND=127.0.0.1:8090 FRIDA_BASE_URL=http://localhost:8090 FRIDA_PATH_PREFIX="" \
//! cargo run -p frida-order
//! ```
//!
//! In production this crate is mounted *behind the consuming app's ingress* at
//! `FRIDA_PATH_PREFIX` (e.g. `/frida`) so the WebAuthn RP-ID/origin matches the app — see
//! `heimdal-frida/DESIGN.md`. The in-memory store is for single-server / demo use only.
use frida_order::{router, AppState};
#[tokio::main]
async fn main() {
tracing_subscriber::fmt().with_max_level(tracing::Level::INFO).init();
let bind = std::env::var("FRIDA_BIND").unwrap_or_else(|_| "127.0.0.1:8090".into());
let base_url = std::env::var("FRIDA_BASE_URL").unwrap_or_else(|_| format!("http://{bind}"));
let path_prefix = std::env::var("FRIDA_PATH_PREFIX").unwrap_or_default();
let state = AppState::new(base_url, path_prefix);
let app = router(state);
let listener = tokio::net::TcpListener::bind(&bind).await.expect("bind");
tracing::info!("frida order API on http://{bind}");
axum::serve(listener, app).await.expect("serve");
}