Skip to content

feat: integrate axios for API requests with automatic retries#65

Open
simplicityf wants to merge 1 commit into
trustflow-protocol:mainfrom
simplicityf:feat/auto-retries
Open

feat: integrate axios for API requests with automatic retries#65
simplicityf wants to merge 1 commit into
trustflow-protocol:mainfrom
simplicityf:feat/auto-retries

Conversation

@simplicityf

Copy link
Copy Markdown

Related Issue

Closes #19

Screenshot

0

Summary

This pull request introduces a centralized, retry-aware HTTP transport for all backend API calls, improving reliability and consistency across the SDK. It replaces ad-hoc fetch usage with an axios/axios-retry-based client, automatically handling transient failures (like network errors, HTTP 429, and 5xx responses). The changes also include expanded test coverage for retry logic and payload encoding, and update documentation to reflect the new behavior.

Backend API reliability and centralization:

  • Added a shared HTTP transport in src/utils/http.ts using axios and axios-retry, with exponential backoff and configurable retry policies for transient backend failures.
  • Migrated all backend SDK endpoints (TrustFlowEscrowClient.getGigs, DisputeClient.raiseDispute/getDispute, requestChallenge, verifyAndGetToken) from fetch to the new centralized, retry-aware HTTP client. [1] [2] [3] [4]
  • Updated error handling to provide consistent, user-friendly error messages for transport and HTTP errors. [1] [2] [3]

Testing improvements:

  • Added comprehensive Jest tests for the new retry policy, backend transport, and contract argument encoding. [1] [2] [3]

Documentation and dependency updates:

  • Updated README.md and docs/API.md to document auto-retry behavior, new API signatures, and architectural decisions. [1] [2] [3] [4]
  • Added axios and axios-retry as dependencies in package.json.
  • Updated the changelog with a summary of these changes.

- Added axios and axios-retry as dependencies.
- Refactored auth challenge and dispute client to use axios for HTTP requests.
- Implemented automatic retries for transient failures in API calls.
- Updated tests to mock axios and verify behavior under various scenarios.
- Created utility functions for error handling and HTTP client creation.
- Added tests for new HTTP client functionality and XDR payload building.
@simplicityf

Copy link
Copy Markdown
Author

@meshackyaro kindly review

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.

Handle auto-retries for API endpoints

1 participant