feat: implement API routing, request validation, transaction formatti…#336
Open
Chrisbankz0 wants to merge 1 commit into
Open
feat: implement API routing, request validation, transaction formatti…#336Chrisbankz0 wants to merge 1 commit into
Chrisbankz0 wants to merge 1 commit into
Conversation
…ng, and custom error handling middleware
Contributor
|
Resolve conflicts |
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.
#closes
#293
Pull Request: StellarKit API Bug Fixes and Endpoint Implementations
Description
This PR resolves all compilation, syntax, runtime, and integration issues in the StellarKit API project, bringing the test suite to 100% pass rate (59/59 test suites, 559/559 tests). It implements missing features, updates routing and validation logic for edge cases, cleans up cache usage, and improves tests resilience on Windows loopback connections.
Key Changes
1. New Endpoint Implementations
src/routes/account.js):GET /account/:id/home-domain: Returns thehome_domainset on the account.GET /account/:id/min-balance: Computes the minimum XLM reserve requirement and breakdown based on subentry counts.GET /account/:id/flags: Formats Horizon snake_case flags into camelCase booleans.GET /account/:id/signers: Exposes all signers, weights, thresholds, and sponsorship details.src/routes/networkStatus.js):GET /network/ledger-timing: Computes close time, variance, standard deviation, and consistency rating across the last 10 ledgers.src/routes/feeEstimate.js):GET /fee-estimate/trends: Analyzes fee trends (rising, falling, stable) and capacity usage over the last 50 ledgers.src/routes/stream.js):GET /stream/ledgers: Implements a Server-Sent Events (SSE) stream for live ledger close events with keep-alive heartbeat pings.2. Bug Fixes & Optimization
tx.ledgerwas returned as a getter function in the JS Stellar SDK, causing it to fail JSON serialization. Changed to a type-safe check (typeof tx.ledger === "number" ? tx.ledger : tx.ledger_attr)./account//sequence) throws a400 ValidationError, whereas a clean action word with missing ID (e.g.,/account/sequence) correctly bypasses route validation to return404 Not Found.cacheimports and adjusted TTL conversion (milliseconds to seconds) fornode-cacheinasset.js,networkStatus.js, andfeeEstimate.js.dex-asset-endpoints.test.jsto return interceptors and.createproperties, preventing Horizon SDK instantiation failure.ReferenceErrorinsideerrorHandler.jsby declaring and using thetranslateHorizonErrorutility to appendcodeand translatedmessagekeys onHorizonErrorpayloads.Verification & Test Results
Verified using both the static code linter and the local Jest environment:
npm run lintcompletes with0 errors.npm testruns with 59 passed test suites (100% green).