style: apply cargo fmt to entire codebase
Standardize code formatting across all 173 Rust source files using rustfmt. No functional changes - purely cosmetic. This establishes a consistent code style baseline for the project going forward.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use std::sync::Arc;
|
||||
use axum::{
|
||||
Json,
|
||||
extract::{Path, State},
|
||||
http::StatusCode,
|
||||
response::IntoResponse,
|
||||
Json,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use tracing::{error, info};
|
||||
|
||||
use crate::application::ports::favorites_ports::FavoritesUseCase;
|
||||
@@ -16,20 +16,21 @@ pub async fn get_favorites(
|
||||
auth_user: AuthUser,
|
||||
) -> impl IntoResponse {
|
||||
let user_id = &auth_user.id;
|
||||
|
||||
|
||||
match favorites_service.get_favorites(user_id).await {
|
||||
Ok(favorites) => {
|
||||
info!("Retrieved {} favorites for user", favorites.len());
|
||||
(StatusCode::OK, Json(serde_json::json!(favorites))).into_response()
|
||||
},
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Error retrieving favorites: {}", err);
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(serde_json::json!({
|
||||
"error": format!("Failed to retrieve favorites: {}", err)
|
||||
}))
|
||||
).into_response()
|
||||
})),
|
||||
)
|
||||
.into_response()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,34 +42,37 @@ pub async fn add_favorite(
|
||||
Path((item_type, item_id)): Path<(String, String)>,
|
||||
) -> impl IntoResponse {
|
||||
let user_id = &auth_user.id;
|
||||
|
||||
|
||||
// Validate item_type
|
||||
if item_type != "file" && item_type != "folder" {
|
||||
return (
|
||||
StatusCode::BAD_REQUEST,
|
||||
StatusCode::BAD_REQUEST,
|
||||
Json(serde_json::json!({
|
||||
"error": "Item type must be 'file' or 'folder'"
|
||||
}))
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
match favorites_service.add_to_favorites(user_id, &item_id, &item_type).await {
|
||||
|
||||
match favorites_service
|
||||
.add_to_favorites(user_id, &item_id, &item_type)
|
||||
.await
|
||||
{
|
||||
Ok(_) => {
|
||||
info!("Added {} '{}' to favorites", item_type, item_id);
|
||||
(
|
||||
StatusCode::CREATED,
|
||||
StatusCode::CREATED,
|
||||
Json(serde_json::json!({
|
||||
"message": "Item added to favorites"
|
||||
}))
|
||||
})),
|
||||
)
|
||||
},
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Error adding to favorites: {}", err);
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(serde_json::json!({
|
||||
"error": format!("Failed to add to favorites: {}", err)
|
||||
}))
|
||||
})),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -81,35 +85,38 @@ pub async fn remove_favorite(
|
||||
Path((item_type, item_id)): Path<(String, String)>,
|
||||
) -> impl IntoResponse {
|
||||
let user_id = &auth_user.id;
|
||||
|
||||
match favorites_service.remove_from_favorites(user_id, &item_id, &item_type).await {
|
||||
|
||||
match favorites_service
|
||||
.remove_from_favorites(user_id, &item_id, &item_type)
|
||||
.await
|
||||
{
|
||||
Ok(removed) => {
|
||||
if removed {
|
||||
info!("Removed {} '{}' from favorites", item_type, item_id);
|
||||
(
|
||||
StatusCode::OK,
|
||||
StatusCode::OK,
|
||||
Json(serde_json::json!({
|
||||
"message": "Item removed from favorites"
|
||||
}))
|
||||
})),
|
||||
)
|
||||
} else {
|
||||
info!("Item {} '{}' was not in favorites", item_type, item_id);
|
||||
(
|
||||
StatusCode::NOT_FOUND,
|
||||
StatusCode::NOT_FOUND,
|
||||
Json(serde_json::json!({
|
||||
"message": "Item was not in favorites"
|
||||
}))
|
||||
})),
|
||||
)
|
||||
}
|
||||
},
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Error removing from favorites: {}", err);
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(serde_json::json!({
|
||||
"error": format!("Failed to remove from favorites: {}", err)
|
||||
}))
|
||||
})),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user