Skip to content

feat(indexer): add REST API endpoints with supertest tests#303

Merged
Levi-Ojukwu merged 2 commits into
Invoice-Liquidity-Network:mainfrom
devonahi:main
Jun 28, 2026
Merged

feat(indexer): add REST API endpoints with supertest tests#303
Levi-Ojukwu merged 2 commits into
Invoice-Liquidity-Network:mainfrom
devonahi:main

Conversation

@devonahi

Copy link
Copy Markdown
Contributor

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

  • Database: SQLite via better-sqlite3 with tables for invoices, events, reputation_updates, stats_snapshots, stats_history
  • API: Express with JSON middleware
  • Caching: In-memory cache with configurable TTL (default 60s) for /stats
  • Tests: 35 supertest tests across 4 suites covering happy paths, edge cases, filtering, pagination, and error cases

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

Levi-Ojukwu and others added 2 commits June 28, 2026 16:07
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
@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Levi-Ojukwu Levi-Ojukwu merged commit 72816ba into Invoice-Liquidity-Network:main Jun 28, 2026
2 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants