Add endpoint handlers
This commit is contained in:
parent
f44d4ab407
commit
d4b66508ee
5 changed files with 297 additions and 0 deletions
22
backend/sync_server/src/server/fetch_latest_documents.rs
Normal file
22
backend/sync_server/src/server/fetch_latest_documents.rs
Normal 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))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue