Add instance configuration UI and backend

This commit is contained in:
2026-04-30 17:45:05 +02:00
parent 1578c3a708
commit 4229444f96
17 changed files with 293 additions and 15 deletions

View File

@@ -1,8 +1,10 @@
use std::error::Error;
use std::{error::Error, sync::Arc};
use axum::Router;
use sqlx::PgPool;
use tokio::net::TcpListener;
use tokio::{net::TcpListener, sync::RwLock};
use crate::config::MnemoConf;
mod api;
mod config;
@@ -21,6 +23,7 @@ const ISE_MSG: &str = "Internal server error";
#[derive(Debug, Clone)]
pub struct MnemoState {
pool: PgPool,
conf: Arc<RwLock<MnemoConf>>,
}
#[tokio::main]
@@ -31,6 +34,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
let pool = config::init_pool().await?;
sqlx::migrate!("src/database/migrations").run(&pool).await?;
log::info!("Migrations applied successfully.");
let conf = Arc::new(RwLock::new(MnemoConf::new()));
users::auth::init_password_dummies();
users::setup::initialise_reserved_users_if_needed(&pool).await?;
@@ -38,7 +42,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
let r = Router::new()
.merge(api::api_router())
.merge(web::web_router())
.with_state(MnemoState { pool });
.with_state(MnemoState { pool, conf });
let l = TcpListener::bind(format!("0.0.0.0:{port}")).await?;
log::info!("Listener bound to {}", l.local_addr()?);