Merged
Conversation
PCBZ
added a commit
that referenced
this pull request
Apr 24, 2025
Optimize database connection error
There was a problem hiding this comment.
Pull Request Overview
This PR focuses on optimizing database connection error handling and authentication flows while refactoring redundant token management. Key changes include:
- Migrating from legacy token handling (using localStorage) to sessionStorage in authentication services.
- Refactoring donor list service calls to use a centralized fetch method from baseService.
- Updating middleware and server error handling responses with structured error messages and clearer comments.
- Removing pull_request triggers from CI workflows to focus solely on push events.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| client/src/services/donorListService.js | Refactored API calls to use fetchWithAuth from baseService |
| client/src/services/baseService.js | Added generic fetchWithAuth function for token-based API calls |
| client/src/services/authService.js | Updated authentication to use sessionStorage and simplified flow |
| client/src/middleware/authMiddleware.js | Changed middleware function naming and error handling |
| client/src/config.js | Moved API configuration to a centralized config file |
| client/src/components/donors/Donors.jsx | Minor debugging log present; otherwise, donor data processing unchanged |
| Server/src/routes/donor.js | Converted comments and error messages to English |
| Server/src/middleware/auth.js | Introduced structured and detailed error responses |
| .github/workflows/docker-build.yml | Removed pull_request trigger |
| .github/workflows/cd.yml | Removed pull_request trigger |
Comments suppressed due to low confidence (1)
client/src/middleware/authMiddleware.js:4
- [nitpick] The function name 'withAuth' might be unclear; consider renaming it to something like 'handleUnauthorizedResponse' to clearly indicate its purpose.
export const withAuth = async (response) => {
| } | ||
| } | ||
|
|
||
| console.log('response.data', response.data); |
There was a problem hiding this comment.
[nitpick] Consider removing the debug log in production code to avoid unintended console output.
Suggested change
| console.log('response.data', response.data); | |
| // Debug log removed: console.log('response.data', response.data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.