use crate::{auth::User, error::Result, user::RepositorySchema};
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();
    app_state.user.add_repository(&user.id, repo).await
}
