Skip to content

Feature/indexer start ledger#176

Open
oluwaseyi1996-netizen wants to merge 4 commits intoritik4ever:mainfrom
oluwaseyi1996-netizen:feature/indexer-start-ledger
Open

Feature/indexer start ledger#176
oluwaseyi1996-netizen wants to merge 4 commits intoritik4ever:mainfrom
oluwaseyi1996-netizen:feature/indexer-start-ledger

Conversation

@oluwaseyi1996-netizen
Copy link
Copy Markdown
Contributor

@oluwaseyi1996-netizen oluwaseyi1996-netizen commented Apr 24, 2026

Closes #150


mplementation Summary
Changes Made to backend/src/services/indexer.ts:

Added environment variable support: Introduced INDEXER_START_LEDGER environment variable reading in initIndexer()
Cursor override logic: Modified the cursor initialization in indexEvents() to use the environment variable when set (except when set to 0)
Warning logging: Added a warning log when the override is active (when INDEXER_START_LEDGER ≠ 0)
Special case handling: When INDEXER_START_LEDGER=0, the system uses the saved cursor or latest ledger (normal behavior)
Error handling: Added validation for invalid numeric values
Key Features
Environment Variable: INDEXER_START_LEDGER read at initIndexer()
Cursor Reset: If set, cursor resets to this value on startup
Warning Log: Logs warning when override is active
Zero Handling: INDEXER_START_LEDGER=0 means "use saved cursor or latest ledger"
Use Case: Perfect for redeploying contracts and forcing backfill from specific ledger
Branch and PR
Branch: feature/indexer-start-ledger has been created and pushed
Pull Request: Ready to create at https://github.com/oluwaseyi1996-netizen/stellar-stream/pull/new/feature/indexer-start-ledger
The implementation meets all acceptance criteria for issue #150 and provides the operational tooling needed for Wave 4.

closes#150

- Add sendError helper function to apiErrors.ts for consistent error handling
- Fix incomplete error handlers in auth endpoints
- Replace all direct res.status().json() error responses with sendApiError calls
- Ensure all 4xx and 5xx responses include requestId for log correlation
- Remove duplicate imports in index.ts
- Fix duplicate variable declarations in start-time endpoint

Fixes ritik4ever#154
- Add documentation comments to clarify requestId usage in error responses
- Enhance requestLogger middleware comments for log correlation
- Ensure all error responses include requestId via existing helper functions
- All 4xx/5xx responses now consistently include requestId for log correlation

Fixes ritik4ever#154
- Update getStreamHistory function to accept limit and offset parameters
- Add countStreamEvents function to get total count for pagination metadata
- Update /api/streams/:id/history endpoint to support ?limit and ?offset query params
- Add validation: default limit 50, max limit 200
- Response includes total count alongside paginated data array
- Fixes ritik4ever#143
- Add INDEXER_START_LEDGER environment variable support
- Override cursor in initIndexer() when environment variable is set
- Log warning when override is active
- Handle special case where INDEXER_START_LEDGER=0 (use saved cursor or latest)
- Useful for redeploying contracts and forcing backfill from specific ledger

Fixes ritik4ever#150
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 24, 2026

@oluwaseyi1996-netizen is attempting to deploy a commit to the ritik4ever's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 24, 2026

@oluwaseyi1996-netizen Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

[wave4][backend] Add configurable start ledger for historical indexer backfill

1 participant