refactor(api): centralize network and contract config for API handlers - #77
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 58 minutes and 42 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ 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 |
|
🚅 Deployed to the MeeChain-Connect-pr-77 environment in meechain 5 services not affected by this PR
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c547918e29
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
meechain-connect | c547918 | May 04 2026, 04:15 PM |
…0e0j33 Signed-off-by: ธณวัฒน์ ประวันตา <pouaun2499@gmail.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com> Signed-off-by: ธณวัฒน์ ประวันตา <pouaun2499@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 170ae1e988
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| contracts: { | ||
| token: contracts.token, | ||
| nft: contracts.nft, | ||
| staking: contracts.portal, |
There was a problem hiding this comment.
Close the health contracts object
The added contracts block is never closed before the old chainId/rpc fields continue, so the ES-module parser reaches the final }; while the outer data object is still open. Any deployment that loads /api/health will fail with a syntax error instead of returning the health JSON; close this block or remove the stale config fields.
Useful? React with 👍 / 👎.
| export async function onRequestGet(ctx) { | ||
| const { env } = ctx; | ||
|
|
||
| const rpcUrl = resolveRpcUrl(env); | ||
| const chainId = resolveChainId(env); | ||
| const contracts = resolveContracts(env); |
There was a problem hiding this comment.
Remove the nested duplicate status handler
The newly inserted onRequestGet starts here but is not closed before the existing import and handler below it, which makes the file invalid as an ES module because the later import is parsed inside a function body. In any Cloudflare Pages deployment that loads /api/web3/status, the route will fail to load; fold these resolver variables into the existing handler or remove this duplicate wrapper.
Useful? React with 👍 / 👎.
Motivation
Description
functions/api/_shared.mjsas a single source of truth exportingDEFAULT_CHAIN_ID,DEFAULT_RPC_URL,DEFAULT_CONTRACTS, and resolver functionsresolveChainId,resolveRpcUrl, andresolveContracts.functions/api/health.jsto import the shared resolvers and useresolveChainId,resolveRpcUrl, andresolveContracts, while preservingcontracts.stakingfor backward compatibility.functions/api/network.jsto useresolveChainId,resolveRpcUrl, andresolveContractsinstead of in-file hard-coded/duplicated values.functions/api/web3/status.jsto use the shared resolvers forrpc,chainId, andcontractsso reported values match other endpoints.Testing
node --check functions/api/_shared.mjsandnode --checkon the updated handlers which completed successfully.npm test -- --grep "api"but the test runner could not execute in this environment becausemochais not installed, so the full test suite did not run.Codex Task