Skip to content

fix: add server-side validation for critical API endpoints#58

Open
Oby38 wants to merge 1 commit into
Kalebtron1:mainfrom
Oby38:fix/server-side-validation
Open

fix: add server-side validation for critical API endpoints#58
Oby38 wants to merge 1 commit into
Kalebtron1:mainfrom
Oby38:fix/server-side-validation

Conversation

@Oby38
Copy link
Copy Markdown

@Oby38 Oby38 commented May 29, 2026

Closes #43

This PR adds explicit request validation for the serverless API endpoints in api/calculate-score.js, api/evaluate-and-mint.js, api/get-available-credit.js, and api/get-user-data.js.

Accepted request shapes:

  • POST /api/calculate-score with { address: string, totalDeposited?: number }
  • POST /api/evaluate-and-mint with { userAddress: string, totalVolume?: number, deposits?: [{ amount: number }] }
  • POST /api/get-available-credit with { userAddress: string }
  • GET /api/get-user-data?address=<string>

Rejected invalid cases:

  • missing required address or userAddress
  • empty string values for required addresses
  • non-numeric or negative values for optional volume fields
  • invalid deposits array items for evaluate-and-mint

A shared helper was introduced at api/validation.js with Zod schemas and consistent 400 responses for bad requests.

Validation performed:

  • npm run build succeeded after installing dependencies
  • direct handler invocation tests showed malformed input returns 400 for each endpoint

@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

@Oby38 is attempting to deploy a commit to the alankcr1-6443's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@Oby38 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! 🚀

Learn more about application limits

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.

Validaciones server-side para entradas criticas

1 participant