feat: add system configuration API endpoint and frontend hook for dynamic settings

This commit is contained in:
2025-12-25 23:41:00 +01:00
parent 529457c9a3
commit 4cb398869d
6 changed files with 64 additions and 8 deletions

View File

@@ -166,3 +166,9 @@ impl From<notes_domain::NoteVersion> for NoteVersionResponse {
}
}
}
/// System configuration response
#[derive(Debug, Serialize)]
pub struct ConfigResponse {
pub allow_registration: bool,
}

View File

@@ -0,0 +1,14 @@
//! Configuration routes
use axum::{Json, extract::State};
use crate::dto::ConfigResponse;
use crate::error::ApiResult;
use crate::state::AppState;
/// Get system configuration
pub async fn get_config(State(state): State<AppState>) -> ApiResult<Json<ConfigResponse>> {
Ok(Json(ConfigResponse {
allow_registration: state.config.allow_registration,
}))
}

View File

@@ -1,6 +1,7 @@
//! Route definitions and module structure
pub mod auth;
pub mod config;
pub mod import_export;
pub mod notes;
pub mod tags;
@@ -40,4 +41,6 @@ pub fn api_v1_router() -> Router<AppState> {
"/tags/{id}",
delete(tags::delete_tag).patch(tags::rename_tag),
)
// System Config
.route("/config", get(config::get_config))
}