-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Apibara reorg patch #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
loothero
merged 40 commits into
next
from
feat/apibara-v2-migration-and-production-hardening
Mar 10, 2026
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
af852ba
chore(indexer): upgrade apibara and switch to accepted finality
loothero 090da3f
add consumables table migration
loothero 8f642d9
register consumables migration in drizzle journal
loothero 02cf96e
chore(indexer): bump drizzle-orm to 0.45.1
loothero 6454a34
chore(indexer): bump pg and @types/pg to latest
loothero c875346
fix(observability): address metrics review findings
Codex-Agent 3e1df5c
fix(api): reduce hot-path logging with sampled structured logs
loothero d24118c
perf(api): add thin strategic response cache
loothero b9443d5
perf(api,indexer): optimize hot queries and add index support
loothero fb11e74
chore(api): add stress test runner script
loothero 440c8e5
docs(indexer): add stress-test benchmarking guidance
loothero 947e7c8
chore(client): point API host to summit-api-production-ca43
loothero e0db113
fix(client): guard null owners in leaderboard address handling
loothero f9898fb
fix(client): prevent ws event crashes on null player addresses
loothero c9b7dd5
fix(indexer): patch apibara drizzle reorg trigger churn
loothero 85f7189
fix(indexer): include pnpm patches in docker build
loothero 4671556
fix(indexer): mark reorg triggers registered after commit
loothero bbd27a5
Set Apibara finality to pending
loothero 3a0910e
perf(indexer): avoid eager id extraction in reorg trigger
loothero 4c384ab
Revert "perf(indexer): avoid eager id extraction in reorg trigger"
loothero c8204ac
perf(indexer): add covering index on rewards_earned(owner, amount)
loothero 091a156
fix(indexer): use IF NOT EXISTS in leaderboard index migration
loothero 3d496f2
fix(indexer): set Railway restart policy to ALWAYS
loothero c38d4a7
fix(indexer): isolate invalidate from block reorg order key txn
loothero dd8fe53
chore: add Railway watch patterns for monorepo PR environments
loothero 347e49e
fix(api): keep /beasts/all total accurate on empty pages
loothero d0f541d
refactor: consolidate address utils, extract API constants, remove ph…
loothero 93f5dc3
fix(client): add missing mock fields in ActionBar and Leaderboard tests
loothero 04806b0
merge: resolve conflicts between feature branch and origin/next
loothero 0b2b148
fix(indexer): include .mjs scripts in ESLint node globals config
loothero be01615
fix(client): remove unused normalizeAddress import in GameDirector
loothero 5be347f
fix(telemetry): harden metrics intervals, empty-block tracking, and W…
loothero 45e7f1a
fix(client): normalize Leaderboard type and handle null owner addresses
loothero 526ffa1
fix(indexer): make reorg trigger registration idempotent across restarts
loothero 13ce183
fix(api): exclude /beasts/:owner from response cache
loothero 1dc8969
docs(api): fix README to match runtime behavior
loothero 2ff2c97
fix(api): make /beasts/all ordering deterministic with NULLS LAST
loothero 0651feb
fix(indexer): remove SIGINT/SIGTERM metric handlers that block gracef…
loothero ad7c9cf
docs(indexer): document split-transaction tradeoff in drizzle patch
loothero 0d13099
fix(api): close HTTP server before draining DB pool on shutdown
loothero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ node_modules/ | |
|
|
||
| # Build output | ||
| dist/ | ||
| .cache/ | ||
|
|
||
| # Environment files | ||
| .env | ||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,13 +24,15 @@ For AI-oriented coding guidance and deeper architecture notes, read `AGENTS.md` | |
| ## Environment | ||
|
|
||
| - `DATABASE_URL` (required) | ||
| - `DATABASE_SSL` (`"true"` or `"false"`; required in production) | ||
| - `DATABASE_SSL` (`"true"` or `"false"`; defaults to `"true"` in production with a warning when unset) | ||
| - `DB_POOL_MAX` (default `15`) | ||
| - `PORT` (default `3001`) | ||
| - `NODE_ENV` (`production` hides debug entries from `/` discovery payload) | ||
| - `API_CACHE_ENABLED` (optional; defaults to enabled in production) | ||
| - `API_CACHE_MAX_ENTRIES` (optional; default `500`) | ||
|
|
||
| Production note: | ||
| - API startup fails fast when `NODE_ENV=production` and `DATABASE_SSL` is unset. | ||
| - When `NODE_ENV=production` and `DATABASE_SSL` is unset, SSL defaults to enabled and a warning is logged. | ||
|
|
||
| ## Quick Start | ||
|
|
||
|
|
@@ -88,18 +90,23 @@ curl http://localhost:3001/health | |
| ### Query Parameters and Response Shapes | ||
|
|
||
| `GET /beasts/all` | ||
| - params: `limit` (default `25`, max `100`), `offset`, `prefix`, `suffix`, `beast_id`, `name`, `owner`, `sort` (`summit_held_seconds|level`) | ||
| - params: `limit` (default `25`, max `100`), `offset`, `prefix`, `suffix`, `beast_id`, `name`, `owner`, `sort` (`summit_held_seconds|level`), `include_total` (`true|false`, default `true`) | ||
| - returns: `{ data: Beast[], pagination: { limit, offset, total, has_more } }` | ||
|
|
||
| `GET /logs` | ||
| - params: `limit` (default `50`, max `100`), `offset`, `category`, `sub_category`, `player` | ||
| - params: `limit` (default `50`, max `100`), `offset`, `category`, `sub_category`, `player`, `include_total` (`true|false`, default `true`) | ||
| - `category`/`sub_category` accept comma-separated values | ||
| - returns: `{ data: LogEntry[], pagination: { limit, offset, total, has_more } }` | ||
|
|
||
| `GET /beasts/stats/top` | ||
| - params: `limit` (default `25`, max `100`), `offset` | ||
| - params: `limit` (default `25`, max `100`), `offset`, `include_total` (`true|false`, default `true`) | ||
| - returns: paginated top beasts sorted by summit hold time, bonus XP, death timestamp | ||
|
|
||
| `include_total=false` behavior: | ||
| - skips `count(*)` query for lower latency | ||
| - returns `pagination.total = null` | ||
| - computes `has_more` via `limit + 1` fetch strategy | ||
|
|
||
| `GET /diplomacy` | ||
| - params: `prefix` (required), `suffix` (required) | ||
| - returns HTTP `400` if either is missing | ||
|
|
@@ -155,7 +162,17 @@ Realtime pipeline: | |
|
|
||
| - Address inputs are normalized to lowercase 66-char `0x`-padded form. | ||
| - API is public read-only (no auth layer). | ||
| - No dedicated caching layer is used. | ||
| - A thin in-memory SWR cache is applied to high-traffic read endpoints: | ||
| - `/beasts/all` (common public list patterns) | ||
| - `/logs` | ||
| - `/beasts/stats/counts` | ||
| - `/beasts/stats/top` | ||
| - `/diplomacy` | ||
| - `/diplomacy/all` | ||
| - `/leaderboard` | ||
| - `/quest-rewards/total` | ||
| - `/consumables/supply` | ||
| - Cached responses include `X-Cache` with `HIT`, `MISS`, `STALE`, or `BYPASS`. | ||
|
Comment on lines
+165
to
+175
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. List Right now this route only appears in the cache note. Anyone scanning the endpoint summary or response-shape sections will miss that it exists and has no documented contract. 🤖 Prompt for AI Agents |
||
| - Graceful shutdown closes WS subscriptions/listeners on `SIGINT`/`SIGTERM`. | ||
|
|
||
| ## Deployment Notes | ||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "$schema": "https://railway.com/railway.schema.json", | ||
| "build": { | ||
| "watchPatterns": ["api/**"] | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document
pagination.totalas nullable wheninclude_total=false.The new behavior returns
pagination.total = null, but the response shapes above still read liketotalis always present as a number. Please spell that out asnumber | nullfor the affected endpoints so clients do not over-assume the shape.🤖 Prompt for AI Agents