feat: add system configuration API endpoint and frontend hook for dynamic settings
This commit is contained in:
@@ -166,3 +166,9 @@ impl From<notes_domain::NoteVersion> for NoteVersionResponse {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// System configuration response
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct ConfigResponse {
|
||||
pub allow_registration: bool,
|
||||
}
|
||||
|
||||
14
notes-api/src/routes/config.rs
Normal file
14
notes-api/src/routes/config.rs
Normal 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,
|
||||
}))
|
||||
}
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user