Skip to content
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

Refactor/api service #302

Merged

Conversation

nicolearagao
Copy link
Member

@nicolearagao nicolearagao commented Jan 22, 2024

This Pull Request introduces a refactor aimed at improving the maintainability and scalability of our API interactions within the application. The core changes involve the creation of apiService and ApiHandler. These changes are intended to decouple API calls from page components, enhancing code modularity and readability.

Creation of apiService: Centralizes the API interaction logic, offering a single point of interaction for different API endpoints.
Introduction of ApiHandler: Abstracts common API handling patterns to reduce code duplication and streamline error handling, request sending, and response processing.

Observations:
In some instances, the abstraction provided by ApiHandler did not align perfectly with the specific requirements. These cases have been left as-is for the time being. I am open to suggestions on how to handle these exceptions better.
This refactor focuses on enhancing the maintainability without altering existing functionalities.

@nicolearagao nicolearagao changed the base branch from main to v2-rewrite January 22, 2024 13:34
@nicolearagao nicolearagao marked this pull request as ready for review January 22, 2024 13:41
src/app/routes.tsx Outdated Show resolved Hide resolved
Copy link
Member

@infinitewarp infinitewarp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As someone who doesn't write a lot of React/TypeScript, I long for module/class/function docstrings to explain briefly their purpose, but I understand that a lot of this is probably just boilerplate React/TS code and the purpose is very obvious to seasoned developers. 🤷

In the Python world, we encourage and enforce at least minimal inline documentation with ruff (and previously via flake8-docstrings), and I know some other mainstream languages have similar encouragement/enforcement tools, but I don't know about JS/TS. Are there standard or common tools we could use here also? As we want to broaden and democratize the ownership and maintenance of quipucords-ui, I would like to see more inline documentation so that contributors don't have to be (as much) experts in the existing code base.

(I'm not blocking this PR to require docs, but I wanted to put these thoughts somewhere to start a conversation.)

Copy link
Contributor

@gitdallas gitdallas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i know we did our video code review, but some reminders along with some other things i've noticed going through

src/app/routes.tsx Outdated Show resolved Hide resolved
src/common/alertsHelper.ts Outdated Show resolved Hide resolved
src/components/sessionContext/SessionProvider.tsx Outdated Show resolved Hide resolved
src/hooks/api/useCredentialApi.ts Outdated Show resolved Hide resolved
src/hooks/api/useCredentialApi.ts Outdated Show resolved Hide resolved
src/hooks/api/useCredentialApi.ts Outdated Show resolved Hide resolved
src/services/apiUtils.ts Outdated Show resolved Hide resolved
src/services/apiUtils.ts Outdated Show resolved Hide resolved
src/services/apiUtils.ts Outdated Show resolved Hide resolved
@gitdallas gitdallas force-pushed the refactor/apiService branch 2 times, most recently from 536c2dc to ddd21d2 Compare January 23, 2024 20:48
src/hooks/api/useCredentialApi.ts Outdated Show resolved Hide resolved
src/hooks/api/useSourceApi.ts Show resolved Hide resolved
src/pages/scans/ScansListView.tsx Outdated Show resolved Hide resolved
src/services/apiConfig.ts Outdated Show resolved Hide resolved
@nicolearagao nicolearagao merged commit 773d039 into quipucords:v2-rewrite Jan 29, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants