fix: align public-api Docker image paths and simplify server config#12204
fix: align public-api Docker image paths and simplify server config#12204kaladinlight merged 6 commits intodevelopfrom
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughCentralized environment validation with a Zod-based Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/public-api/src/env.ts`:
- Around line 4-5: Replace the loose validator "const flag =
z.string().transform(v => v === 'true')" with a strict enum-based validator so
only the literals "true" or "false" are accepted; change the schema for the
feature-flag (the const named flag in this module) to use
z.enum(['true','false']) and then transform the validated string to a boolean
(e.g., .transform(v => v === 'true')), which will cause invalid values (like
"TRUE", "1", typos, or extra whitespace) to fail validation at startup instead
of silently mapping to false.
- Around line 8-9: Tighten the zod schemas for numeric and boolean env vars:
validate PORT and DEFAULT_AFFILIATE_BPS using a numeric regex (e.g.,
.regex(/^\d+$/, 'PORT must be numeric') / 'DEFAULT_AFFILIATE_BPS must be
numeric') instead of allowing any string, change all RATE_LIMIT_* fields to use
integer validation (e.g., .int().min(1) or similar) so empty strings or
non-numeric values fail validation, and update the feature flag fields
referenced around the feature flag block (lines 61-63 and 65-75) to explicitly
validate booleans (reject invalid strings rather than coercing to false) using
zod boolean parsing or a stricter pre-parse with .refine/.transform to produce
clear error messages; update the schema entries for PORT, DEFAULT_AFFILIATE_BPS,
each RATE_LIMIT_* key, and the feature flag keys accordingly.
In `@packages/public-api/src/routes/affiliate/getAffiliateStats.ts`:
- Around line 61-62: The code builds backendUrl using new
URL(`/swaps/affiliate-fees/${address}`, env.SWAP_SERVICE_BASE_URL) which drops
any service prefix in SWAP_SERVICE_BASE_URL; change it to build the endpoint
using string concatenation instead (e.g., combine env.SWAP_SERVICE_BASE_URL with
"/swaps/affiliate-fees/" + address) so the service prefix is preserved; update
the backendUrl assignment in getAffiliateStats.ts (the const backendUrl
variable) accordingly and ensure any subsequent usage expects a string or new
URL(...) constructed from the full concatenated string.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b5d38514-dc60-4fcd-b3ce-4f7174f61059
📒 Files selected for processing (10)
packages/public-api/.env.examplepackages/public-api/src/config.tspackages/public-api/src/env.tspackages/public-api/src/index.tspackages/public-api/src/middleware/auth.tspackages/public-api/src/middleware/rateLimit.tspackages/public-api/src/routes/affiliate/getAffiliateStats.tspackages/public-api/src/routes/status/getSwapStatus.tspackages/public-api/src/routes/status/utils.tspackages/public-api/src/swapperDeps.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/public-api/src/index.ts
Summary
__dirname-relative paths work for both docs and asset data — no env vars neededtrust proxy: 1(required forexpress-rate-limitto correctly identify client IPs behind Railway's proxy)PORT— noparseIntneeded sinceapp.listenaccepts stringsAPI_HOST,API_PORTconfig andTRUST_PROXY/ASSET_DATA_PATHenv vars__dirname-relative path instead of a fallback arrayTest plan
/healthresponds correctly/docsloads without ENOENT errorstrust proxy: 1🤖 Generated with Claude Code
Summary by CodeRabbit