fix(x402): share single validated config across Express and Vercel ru… - #379
Merged
Merged
Conversation
|
@DevRushd 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! 🚀 |
|
@DevRushd is attempting to deploy a commit to the Emmanuel's projects Team on Vercel. A member of the Team first needs to authorize it. |
AbuJulaybeeb
requested changes
Sep 1, 2026
AbuJulaybeeb
left a comment
Collaborator
There was a problem hiding this comment.
rebase the whole branch
…ntimes (Emmy123222#108) Introduce src/lib/x402Config.ts as the single source of truth for x402 payment route and asset configuration. Both Express (server/index.ts) and Vercel (api/search.ts) now import this module, eliminating protocol drift between the two runtimes. Changes: - New src/lib/x402Config.ts with validated getters for network, asset, amount, payTo, timeout, and fee sponsorship - server/index.ts updated to use buildExpressRoutes() from x402Config - api/search.ts updated to use buildPaymentRequiredPayload() from x402Config - 25 new snapshot tests in x402Config.test.ts comparing Express/Vercel output - validateQuery.test.ts env setup fixed for x402Config initialization Closes Emmy123222#108 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
DevRushd
force-pushed
the
fix/108-shared-x402-config
branch
from
September 2, 2026 11:40
a82df30 to
728198e
Compare
Contributor
Author
|
@AbuJulaybeeb I have resolved conflicts and rebase the branch. Kindly review and merge |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Share one x402 route and asset configuration across runtimes
Problem
Express (
server/index.ts) and Vercel (api/search.ts) each independently hardcoded their own x402 payment configuration — network, asset, amount,payTo, timeout, and fee sponsorship. Any future change to one runtime's config could silently drift out of sync, breaking payment consistency across deployments.Solution
Created a single validated source of truth at
src/lib/x402Config.tsthat both runtimes consume:X402Configinterface — typed configuration object with runtime validationgetX402Config()— memoized function that reads fromconstants.tsand validates all required fields on first call, throwing descriptive errors for missing/invalid valuesbuildPaymentRequiredPayload()— generates a standards-compliantx402-payment-requiredresponse body from the shared config (used by Vercel)buildExpressRoutes()— mounts the x402 payment middleware on Express routes using the same shared config (used by Express)getX402ConfigSnapshot()— exported for snapshot testingBoth
server/index.tsandapi/search.tsnow import from this single module instead of defining config inline.Files Changed
src/lib/x402Config.tssrc/lib/x402Config.test.tsserver/index.tsbuildExpressRoutes()from shared configapi/search.tsbuildPaymentRequiredPayload()from shared configserver/validateQuery.test.tsTests
x402Config.test.tscovering:Validation
tsc --noEmit) for server, API, and frontend configsupstream/main— no merge conflictsCloses #108