Skip to content

refactor: introduce shared zod schemas as a typed API contract across faucet/register-kyc/relay-withdraw #118

Description

@tech-adrian

Problem

frontend/src/app/api/faucet/route.ts, api/register-kyc/route.ts, and api/relay-withdraw/route.ts each independently define and validate their own request/response shapes, with no shared schema layer connecting the server-side validation to the frontend callers that construct these requests.

Why it matters

Without a single source of truth for these shapes, a server-side field rename or validation change can silently desync from frontend callers, surfacing only at runtime — exactly the kind of gap that produces confusing errors instead of the friendly ones tracked in #29/#15.

Scope

  • New frontend/src/lib/schemas/ directory with zod schemas for each of the three routes' request/response shapes.
  • frontend/src/app/api/faucet/route.ts, api/register-kyc/route.ts, api/relay-withdraw/route.ts: validate incoming requests against the shared schema.
  • Frontend callers (in deposit/page.tsx, withdraw/page.tsx, compliance/page.tsx, or a shared lib/api-client.ts): use the same schemas to type outgoing requests and parse responses.
  • Tests confirming schema validation rejects malformed input for each route.

Acceptance criteria

  • Request/response shapes for all three API routes are defined once and imported by both server and client code, with no duplicated shape definitions.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions