feat(indexer): add REST API endpoints with supertest tests#303
Merged
Conversation
Implement the ILN indexer REST API covering Issues Invoice-Liquidity-Network#250-Invoice-Liquidity-Network#253: - GET /leaderboard: materialized reputation ranking with limit and token filter - GET /reputation/:address: reputation profile with score history and period filtering - GET /stats: pre-computed protocol metrics with 60s in-memory cache + history endpoint - GET /invoices/:id: full invoice detail with event history and computed fields Database layer uses SQLite (better-sqlite3) with tables for invoices, events, reputation_updates, stats_snapshots, and stats_history. Express REST API with 35 supertest tests across 4 test suites.
feat(indexer): add REST API endpoints with supertest tests
|
@devonahi 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! 🚀 |
72816ba
into
Invoice-Liquidity-Network:main
2 of 7 checks passed
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.
Summary
Implements the ILN indexer REST API covering Issues #250–#253. Creates the indexer/ package from scratch with a SQLite-backed Express server and 35 supertest tests.
New endpoints
Endpoint Issue Description
GET /leaderboard?limit=50&token=USDC #253 Materialized reputation ranking sorted by score. Respects limit (max 100), optional ?token= filter
GET /reputation/:address?historyPeriod=30d|90d|all #252 Full reputation profile with score history. Returns zero-score for unknown addresses (no 404)
GET /stats #251 Pre-computed protocol metrics (invoice counts, volume by token, dispute rate) with 60s in-memory cache TTL
GET /stats/history?period=30d|90d #251 Time-series daily aggregates for stats history
GET /invoices/:id #250 Full invoice detail with event history, computed fields (effectiveYieldBps, remainingBalance, daysUntilExpiry), 404 for unknown IDs
Architecture
Files added (21)
indexer/
├── package.json, tsconfig.json, jest.config.cjs, .gitignore
├── src/
│ ├── index.ts, app.ts, config.ts
│ ├── database/db.ts, schema.ts
│ ├── services/leaderboardService.ts, statsService.ts
│ └── api/routes/leaderboard.ts, reputation.ts, stats.ts, invoices.ts
└── tests/
├── helpers.ts
├── leaderboard.test.ts, reputation.test.ts, stats.test.ts, invoices.test.ts
closes #250
closes #251
closes #252
closes #253