use axum::Json;
use crate::models::ApiResponse;
use crate::utils::sanitize::SanitizeOutput;

pub fn success_response<T: SanitizeOutput>(data: T) -> Json<ApiResponse<T>> {
    Json(ApiResponse {
        success: true,
        data: Some(data.sanitize_output()),
        message: None,
    })
}

pub fn success_with_message<T: SanitizeOutput>(data: T, message: &str) -> Json<ApiResponse<T>> {
    Json(ApiResponse {
        success: true,
        data: Some(data.sanitize_output()),
        message: Some(message.to_string()),
    })
}

