Refactor handlers and OpenAPI documentation for improved readability and consistency
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 6m49s
test / unit (pull_request) Successful in 16m24s
test / integration (pull_request) Failing after 17m7s

- Reorganized imports in health, notifications, social, thoughts, and users handlers for clarity.
- Updated function signatures in handlers to improve readability by aligning parameters.
- Enhanced JSON response formatting in notifications and thoughts handlers.
- Improved error handling in user-related functions.
- Refactored OpenAPI documentation to maintain consistent formatting and structure.
- Cleaned up unnecessary code and comments across various files.
- Ensured consistent use of `Arc` for shared state in AppState and WorkerHandlers.
This commit is contained in:
2026-05-14 16:28:57 +02:00
parent 004bfb427b
commit 10c4a66de5
47 changed files with 2406 additions and 723 deletions

View File

@@ -1,6 +1,6 @@
use crate::{errors::ApiError, state::AppState};
use axum::{extract::FromRequestParts, http::request::Parts};
use domain::value_objects::UserId;
use crate::{errors::ApiError, state::AppState};
pub struct AuthUser(pub UserId);
pub struct OptionalAuthUser(pub Option<UserId>);
@@ -8,7 +8,8 @@ pub struct OptionalAuthUser(pub Option<UserId>);
impl FromRequestParts<AppState> for AuthUser {
type Rejection = ApiError;
async fn from_request_parts(parts: &mut Parts, state: &AppState) -> Result<Self, ApiError> {
extract_user_id(parts, state).await?
extract_user_id(parts, state)
.await?
.ok_or(ApiError::Unauthorized)
.map(AuthUser)
}
@@ -25,7 +26,11 @@ async fn extract_user_id(parts: &mut Parts, state: &AppState) -> Result<Option<U
if let Some(auth_header) = parts.headers.get("Authorization") {
if let Ok(s) = auth_header.to_str() {
if let Some(token) = s.strip_prefix("Bearer ") {
return state.auth.validate_token(token).map(Some).map_err(|_| ApiError::Unauthorized);
return state
.auth
.validate_token(token)
.map(Some)
.map_err(|_| ApiError::Unauthorized);
}
}
}