Refactor and improve API layer architecture#2040
Merged
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
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.
Pull Request Description
This PR completely refactors and reworks the current API layer to be more robust and allow for better support for future API versions (e.g., Lemmy API v4). This is a large PR so there may be bugs or issues that I haven't caught yet. I have done some general testing and it seems to be working as expected!
Here's a high level overview of the changes:
ApiClientFactorywhich creates the appropriate API client based on a givenaccount's platform (e.g., Lemmy/PieFed).ThunderApiClientclass which defines all the available API functions. These functions will be implemented by the respective API clients.BaseApiClientwhich handles all logic related to requests/responses and error handling that is shared amongst all the respective API clients. Both the Lemmy/PieFed APIs will extend from this class and implement the methods defined inThunderApiClient.What's left to do now is to implement the changes introduced in Lemmy API V4 and additional testing! I expect there to be some more changes to the architecture as I work on implementing the changes introduced in V4. However, that will be in a different PR and the work will be iterated on.
I'll likely push these changes out to a nightly release first to allow for more time to catch any issues that come up with this refactor.
Issue Being Fixed
Issue Number: N/A
Screenshots / Recordings
Checklist
semanticLabels where applicable for accessibility?