This repository was archived by the owner on Jan 19, 2026. It is now read-only.
refactor: add API client - #52
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces an ApiClient class to refactor the codebase away from individual API functions toward a centralized client pattern. The refactor improves testability by consolidating API interactions into a single client with comprehensive integration tests.
- Replaces scattered API functions with a structured
ApiClientclass that provides organized methods for different API endpoints - Adds comprehensive test infrastructure with Vitest configuration and integration tests covering all major API operations
- Updates the main application code to use the new client pattern while maintaining existing functionality
Reviewed Changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/api/client.ts |
Implements the new ApiClient class with methods for organizations, projects, feature flags, insights, dashboards, queries, and users |
tests/api/client.test.ts |
Comprehensive integration tests covering all ApiClient functionality with proper setup and cleanup |
src/index.ts |
Refactors existing code to use the new ApiClient instead of individual API functions |
vitest.config.ts |
Test configuration for the new testing infrastructure |
tests/setup.ts |
Test environment setup loading test-specific environment variables |
package.json |
Adds testing dependencies and scripts |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
tests/api/client.test.ts:367
- Skipped test reduces coverage for SQL insight functionality. Consider implementing the test or adding a comment explaining why it's skipped.
it.skip("should execute SQL insight query", async () => {
jonathanlab
approved these changes
Jul 22, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
First step of a refactor. We're utilising various functions to interact with the API. Let's pull this out into an API client we can test better.
Adds
posthogApi.tsfunctions