-
Notifications
You must be signed in to change notification settings - Fork 0
✨ extract set_user function and implement loadUserPageVariables pattern #1096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
douglasduteil
merged 12 commits into
master
from
douglasduteil/refactor-get-user-by-id-dynamic-columns
Sep 11, 2025
Merged
✨ extract set_user function and implement loadUserPageVariables pattern #1096
douglasduteil
merged 12 commits into
master
from
douglasduteil/refactor-get-user-by-id-dynamic-columns
Sep 11, 2025
Conversation
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
Contributor
douglasduteil
commented
Sep 10, 2025
- Extract set_user middleware logic to loadUserPageVariables function
- Implement type-safe context variables using factory pattern
- Refactor GetUserById to support dynamic column selection with generics
- Add comprehensive tests for GetUserById with real database testing
- Follow clean architecture patterns for data loading
- Establish naming convention: loadPageVariables for context data loading
- Extract set_user middleware logic to loadUserPageVariables function - Implement type-safe context variables using factory pattern - Refactor GetUserById to support dynamic column selection with generics - Add comprehensive tests for GetUserById with real database testing - Follow clean architecture patterns for data loading - Establish naming convention: loadPageVariables for context data loading
- Add loadModerationPageVariables function for consolidated data loading - Add loadOrganizationPageVariables function following same pattern - Update context types to use Awaited<ReturnType<...>> for automatic type inference - Document Page Variables Pattern convention in CONTRIBUTING.md - Establish consistent naming: loadDomainPageVariables (e.g., loadUserPageVariables) - Consolidate complex data loading logic into single source functions - Enable better maintainability and type safety across domains
…ment - Create reusable set_variables utility function in app/middleware/context/ - Replace middleware pattern with simple helper for bulk context variable setting - Update users and organizations routes to use set_variables with loadPageVariables - Fix TypeScript errors: remove missing GetOrganizationById export, add z_email_domain import - Fix test syntax: use rejects.toThrow() for async promise rejection testing - Maintain full type safety in route handlers while reducing code duplication
- Remove deprecated set_context_variables function and tests - Refactor moderations/:id route to use set_variables with loadModerationPageVariables - Refactor organizations/domaines route to use set_variables with loadDomainesPageVariables - Update set_variables tests with Hono compatibility test - Achieve complete unification: all complex routes now use consistent pattern - Simplify codebase by removing 85 lines of complex middleware code Benefits: - Single responsibility: set_variables only handles bulk variable assignment - Better maintainability: consistent pattern across all routes - Improved testability: simple helper function vs complex middleware - Type safety preserved: each route maintains proper TypeScript types
…y migration - Unified all remaining API routes to use consistent set_variables pattern - Migrated get_users_list to users repository following factory pattern - Added comprehensive test suite for GetUsersList with snapshots - Updated CONTRIBUTING.md with snapshot testing convention - Request processing stays in middleware, page_title in render functions - Clean architecture: data loading consolidated in loadPageVariables functions
- Updated repository testing conventions with real-world examples - Added time control, multiple seed functions, and comprehensive coverage guidelines - Enhanced example with GetUsersList showing snapshot testing best practices - Documented mixed approach: snapshots for comprehensive validation + targeted assertions - Included specific testing requirements for CRUD, edge cases, filtering, pagination
- Replace GetFicheOrganizationById usecase with GetOrganizationById repository in API contexts - Eliminate duplicate organization fetching in organizations/:id route - Consolidate organization and organization_fiche into single repository call - Add missing columns for complete organization data (cached_categorie_juridique, etc.) - Maintain backward compatibility while improving performance and consistency
4077f05
to
7f38d45
Compare
Add better test structure with explicit row navigation and context resets to ensure stable domain status verification in moderation workflow.
Replace manual useRequestContext<IdentiteProconnect_Pg_Context>() calls with usePageRequestContext from local context in duplicate warning component. This follows the established pattern of using typed page contexts instead of manual context access.
🚀 This pull request is included in v2025.9.0. See Release 2025.9.0 for release notes. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
📚 lib
🏗️ infra
🗄️ database
🌐 api
Global, connected routes handling requests.
📝 documentation
Documentation.
scope: app
scope: moderations
scope: organizations
scope: users
🚥 e2e
End-to-end testing (flow check)
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.