rustploy 0.1.10

Rustploy PaaS daemon — lightweight self-hosted deployment platform
//! `Command::ProjectUpdate`: renomeia/redescreve um projeto.

use crate::bootstrap::state::AppState;
use shared::Response as RpResponse;

pub async fn handle(
    state: AppState,
    id: String,
    name: String,
    description: Option<String>,
) -> RpResponse {
    if name.trim().is_empty() {
        return RpResponse::err("InvalidInput", "nome do projeto não pode ser vazio");
    }
    match crate::store::projects::update(&state.db, &id, name, description).await {
        Ok(Some(p)) => RpResponse::Project(Box::new(p)),
        Ok(None) => RpResponse::err("NotFound", "project not found"),
        Err(e) => RpResponse::err(
            "DatabaseError",
            crate::platform::errors::humanize_db_error(&e, "projeto"),
        ),
    }
}