More endpoints

This commit is contained in:
lewis
2025-12-08 17:04:00 +02:00
parent 7ec4861cde
commit a2b2c5b4c9
20 changed files with 2515 additions and 32 deletions
+45 -1
View File
@@ -2,12 +2,13 @@ use crate::state::AppState;
use axum::body::Bytes;
use axum::{
Json,
extract::State,
extract::{Query, State},
http::StatusCode,
response::{IntoResponse, Response},
};
use cid::Cid;
use multihash::Multihash;
use serde::{Deserialize, Serialize};
use serde_json::json;
use sha2::{Digest, Sha256};
use sqlx::Row;
@@ -136,3 +137,46 @@ pub async fn upload_blob(
}))
.into_response()
}
#[derive(Deserialize)]
pub struct ListMissingBlobsParams {
pub limit: Option<i64>,
pub cursor: Option<String>,
}
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RecordBlob {
pub cid: String,
pub record_uri: String,
}
#[derive(Serialize)]
pub struct ListMissingBlobsOutput {
pub cursor: Option<String>,
pub blobs: Vec<RecordBlob>,
}
pub async fn list_missing_blobs(
State(_state): State<AppState>,
headers: axum::http::HeaderMap,
Query(_params): Query<ListMissingBlobsParams>,
) -> Response {
let auth_header = headers.get("Authorization");
if auth_header.is_none() {
return (
StatusCode::UNAUTHORIZED,
Json(json!({"error": "AuthenticationRequired"})),
)
.into_response();
}
(
StatusCode::OK,
Json(ListMissingBlobsOutput {
cursor: None,
blobs: vec![],
}),
)
.into_response()
}
+1 -1
View File
@@ -2,6 +2,6 @@ pub mod blob;
pub mod meta;
pub mod record;
pub use blob::upload_blob;
pub use blob::{list_missing_blobs, upload_blob};
pub use meta::describe_repo;
pub use record::{apply_writes, create_record, delete_record, get_record, list_records, put_record};