All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 2m51s
1.6 KiB
1.6 KiB
Project Optimizations TODO
1. Consolidate and Refine Error Handling (src/errors.rs)
- Split errors into two domains:
StartupError: For config parsing, database connection pooling, and server binding failures (can returneyreoranyhow::Errorinmain.rs).ApiError: Dedicated exclusively to HTTP responses.
- Add
tracing::error!logging in theIntoResponseimplementation for internal server errors (likeDbConnect) before returning generic error JSON to clients.
2. Reduce Boilerplate in Controllers (src/controller/)
- Leverage Axum's
FromRequestandIntoResponsetraits more heavily on models. - Implement a custom extractor (e.g., using
validatorcrate) to ensure controller signatures guarantee valid data (e.g.,ValidJson(payload)).
3. State Management (src/state.rs)
- Audit state struct to ensure
PgPoolis not wrapped in an unnecessaryArc(since it is already anArcinternally). - Ensure application state leverages Axum's
FromReftrait effectively for sub-components.
4. Separation of Concerns in Database Repositories
- Update
user_repository.rsandrefresh_token_repository.rsmethods to accept&sqlx::PgPoolor&mut sqlx::Transactionas arguments to support multi-table atomic transactions cleanly.
5. Clean up Middleware (src/controller/middleware/)
- Ensure
auth_middleware.rsproperly passes the authenticated user downstream usingExtensionorState. - Create a
CurrentUserExtractor so route handlers can easily extract the user viaasync fn get_profile(user: CurrentUser)instead of manually extracting extensions.