Add endpoint handlers

This commit is contained in:
Andras Schmelczer 2024-12-08 14:23:07 +00:00
parent f44d4ab407
commit d4b66508ee
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
5 changed files with 297 additions and 0 deletions

View file

@ -0,0 +1,22 @@
use crate::app_state::AppState;
use crate::database::models::DocumentVersionWithoutContent;
use crate::database::models::VaultId;
use crate::errors::server_error;
use crate::errors::SyncServerError;
use axum::extract::Path;
use axum::extract::State;
use axum::Json;
#[axum::debug_handler]
pub async fn fetch_latest_documents(
Path(vault_id): Path<VaultId>,
State(state): State<AppState>,
) -> Result<Json<Vec<DocumentVersionWithoutContent>>, SyncServerError> {
let latest_version = state
.database
.get_latest_documents(&vault_id, None)
.await
.map_err(server_error)?;
Ok(Json(latest_version))
}