feat: add repo validation

This commit is contained in:
2026-01-20 15:58:10 -08:00
parent 856bde3d97
commit 43c9b7c238
8 changed files with 83 additions and 23 deletions

27
api/src/validate.rs Normal file
View File

@@ -0,0 +1,27 @@
use actix_web::web;
use crate::AppState;
use crate::error::{Error, Result};
use crate::user::RepositorySchema;
pub async fn validate_repo(app_state: web::Data<AppState>, repo: &RepositorySchema) -> Result<()> {
let response = app_state
.reqwest_client
.get(format!(
"https://raw.githubusercontent.com/{}/HEAD/dist/index.html",
repo.full_name
))
.send()
.await?;
match response.status() {
reqwest::StatusCode::OK => Ok(()),
reqwest::StatusCode::NOT_FOUND => Err(Error::ValidationFailed(
"dist/index.html not found in repository".to_string(),
)),
status => Err(Error::ValidationFailed(format!(
"failed to validate repository: HTTP {}",
status
))),
}
}