Production hardening: Remove deprecations, optimize chain queries, enforce explicit configuration #134
Reference in New Issue
Block a user
Delete Branch "copilot/fix-production-readiness-issues"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Addresses 5 production readiness issues: deprecated rate-limit API, inefficient blockchain queries, implicit testnet fallbacks, unclear Prisma setup, and unpinned Docker images.
Changes
1. Rate limit middleware (express-rate-limit v8)
onLimitReachedcallbackhandlerfunction2. Blockchain event queries
fromBlock: 0(full chain scan) with last 1M blocks defaultREGISTRY_START_BLOCKenv var for contract deployment blockblock-range.util.ts3. RPC URL configuration
|| "https://sepolia.base.org"fallbacks across codebaseRPC_URL4. Prisma schema documentation
Added comments explaining dual generator setup (root API vs Next.js web app node_modules)
5. Docker images
Pinned Redis:
redis:7-alpine→redis:7.2-alpineTesting
test/utils/block-range.util.test.tswith 15 comprehensive test casesOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Pull request overview
This PR addresses five production hardening issues related to deprecated APIs, blockchain query performance, configuration safety, documentation clarity, and Docker image versioning. The changes improve production readiness by removing testnet fallbacks, optimizing event queries, and clarifying system architecture.
Changes:
onLimitReachedtohandlercallback in express-rate-limit v8fromBlock: 0with configurable starting block (REGISTRY_START_BLOCK env var or last 1M blocks)Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
onLimitReachedcallbackfromBlock: 0withgetStartBlock()for optimized event queriesonLimitReachedtohandlerwith integrated loggingredis:7-alpinetoredis:7.2-alpine💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@@ -0,0 +37,4 @@// Default to last 1 million blocks (avoids full chain scan while being comprehensive)const currentBlock = await provider.getBlockNumber();return Math.max(0, currentBlock - 1000000);}The new
getStartBlockutility function lacks test coverage. Other utilities in this codebase have corresponding test files (e.g.,error-response.util.test.ts). This function involves important logic including environment variable parsing and blockchain interaction that should be tested to ensure correct behavior with different REGISTRY_START_BLOCK values and edge cases.@copilot apply changes based on the comments in this thread
@@ -0,0 +37,4 @@// Default to last 1 million blocks (avoids full chain scan while being comprehensive)const currentBlock = await provider.getBlockNumber();return Math.max(0, currentBlock - 1000000);}Added comprehensive test coverage in commit
6d484b2. The new test file includes 15 test cases covering:Tests follow the same pattern as error-response.util.test.ts with proper setup/teardown and environment variable handling.