-
Notifications
You must be signed in to change notification settings - Fork 273
Description
Issue Description
The current implementation of the getUsers
function in the users controller tightly couples business logic with query parameters, such as directly using req.query.departed
, req.query.dev
, req.query.profile
, etc., within the business logic. This approach reduces maintainability, makes the code harder to test, and introduces potential issues when adding new query parameters in the future.
To resolve this, the query parameters should be transformed and validated before being passed to services or models. This will decouple the query parameter handling from the core business logic, creating a cleaner and more modular design. Refactoring in this way will also improve the flexibility of the system, making it easier to extend or modify in the future while enhancing testability.
Expected Behavior
- Refactor the
getUsers
function to decouple query parameters from business logic. - Ensure that query parameters (e.g.,
departed
,dev
,profile
) are transformed and validated before passing them into services or models. - Introduce a validation layer that processes query parameters and passes them in a consistent format to the service layer.
- The refactor should be applied consistently across the
getUsers
function to set a good precedent for future code development and maintainability.
Current Behavior
Currently, the getUsers
function relies directly on req.query
for parameters like departed, dev, and profile, which introduces tight coupling between the API handler and the request object. This approach makes the code harder to maintain, extend, and test, especially as more query parameters are added in the future.
Reproducibility
- This issue is reproducible
- This issue is not reproducible
Severity/Priority
- Critical
- High
- Medium
- Low
Additional Information
- The proposed refactor will improve maintainability and promote better separation of concerns.
- By reducing direct dependencies on query parameters, the system will be more robust to future changes and less prone to bugs related to query handling.
- The existing code structure with direct use of req.query is prone to confusion and errors, which this change aims to prevent.
Checklist
- I have read and followed the project's code of conduct.
- I have searched for similar issues before creating this one.
- I have provided all the necessary information to understand and reproduce the issue.
- I am willing to contribute to the resolution of this issue.