Skip to content

feat(proxy): price proxied calls per HTTP method - #1476

Open
lienhoatienphung-svg wants to merge 1 commit into
CalloraOrg:mainfrom
lienhoatienphung-svg:feat/1226-price-proxied-calls-per-http-method
Open

lienhoatienphung-svg wants to merge 1 commit into
CalloraOrg:mainfrom
lienhoatienphung-svg:feat/1226-price-proxied-calls-per-http-method

Conversation

@lienhoatienphung-svg

Copy link
Copy Markdown

Closes #1226

Summary

Adds optional price_per_method_usdc?: Partial<Record<HttpMethod, string>> to ApiDefinition (src/types/gateway.ts), adds resolveMethodPriceUsdc(api, method) and getMethodPriceUsdc(slugOrId, method) in src/data/apiRegistry.ts (normalizing method names case-insensitively and falling back to price_per_call_usdc), and updates handleProxy (src/routes/proxyRoutes.ts) to resolve the price for req.method when deducting credits and recording usage events.

Acceptance Criteria Mapping

  • An API with price_per_method_usdc: { GET: "0.005", POST: "0.02" } charges 0.005 on GET and 0.02 on POST: Verified in src/data/apiRegistry.test.ts and src/routes/gatewayRoutes.test.ts.
  • An HTTP method not listed in price_per_method_usdc charges price_per_call_usdc: Verified via PUT fallback in both unit and route tests.
  • Method lookup is case-insensitive: Normalized via method.trim().toUpperCase().
  • Usage events record the method-specific price: usageStore.record receives amountCharged: priceUsdc.

Validation

  • npx jest src/data/apiRegistry.test.ts src/routes/gatewayRoutes.test.ts --no-cache (all pass).

Payout Wallet (Base Mainnet USDC / EVM): 0x3806cd592a508d1992Ed007C2F53de251C2E7452

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Price proxied calls per HTTP method

1 participant