feat: add repo validation
This commit is contained in:
@@ -1,19 +1,15 @@
|
||||
use crate::{auth::User, error::Result, user::RepositorySchema};
|
||||
use crate::{auth::User, error::Result, user::RepositorySchema, validate::validate_repo};
|
||||
use actix_web::{HttpResponse, web};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::AppState;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct AddResponse {
|
||||
id: String,
|
||||
}
|
||||
|
||||
pub async fn add_repo(
|
||||
app_state: web::Data<AppState>,
|
||||
user: web::ReqData<User>,
|
||||
payload: web::Json<RepositorySchema>,
|
||||
) -> Result<HttpResponse> {
|
||||
let repo = payload.into_inner();
|
||||
validate_repo(app_state.clone(), &repo).await?;
|
||||
app_state.user.add_repository(&user.id, repo).await
|
||||
}
|
||||
|
||||
8
api/src/endpoints/global_repos.rs
Normal file
8
api/src/endpoints/global_repos.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use crate::error::Result;
|
||||
use actix_web::{HttpResponse, web};
|
||||
|
||||
use crate::AppState;
|
||||
|
||||
pub async fn global_repos(app_state: web::Data<AppState>) -> Result<HttpResponse> {
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod add_repo;
|
||||
pub mod get_repos;
|
||||
pub mod global_repos;
|
||||
pub mod search_repos;
|
||||
|
||||
Reference in New Issue
Block a user