Skip to content

feat: cursor pagination, standardized error DTO, and Zod hardening #681

Merged
Mimah97 merged 3 commits into
Vatix-Protocol:devfrom
Emeka000:feat/orders-cursor-pagination-error-dto-zod
Jun 30, 2026
Merged

feat: cursor pagination, standardized error DTO, and Zod hardening #681
Mimah97 merged 3 commits into
Vatix-Protocol:devfrom
Emeka000:feat/orders-cursor-pagination-error-dto-zod

Conversation

@Emeka000

@Emeka000 Emeka000 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add cursor pagination to GET /orders #562 Cursor pagination for GET /orders/user/:address — fixed stale offset-pagination tests (skip, total, page) that were mismatched with the existing cursor-based implementation; updated assertions to use nextCursor, hasNext, take: limit+1; added tests for nextCursor generation, invalid cursor (400), and cursor-driven next-page fetch
  • Standardize error DTO in global error handler #564 Standardize error DTO — added code field to ErrorResponse (VALIDATION_ERROR, NOT_FOUND, UNAUTHORIZED, FORBIDDEN, INTERNAL_ERROR, BAD_REQUEST); resolveCode() helper in errorHandler.ts; covered by new tests
  • Harden order body validation with zod schemas #563 Harden order body validation with Zod — replaced z.string().min(1) on userAddress with STELLAR_PUBLIC_KEY_REGEX so malformed Stellar keys are caught at the Zod layer before any DB call; added zod to dependencies

Test plan

  • GET /orders/user/:address — response shape: nextCursor, hasNext, limit; no total or page
  • GET /orders/user/:address?limit=2 with 3 DB rows → hasNext: true, nextCursor is a string, orders.length === 2
  • GET /orders/user/:address?cursor=<invalid> → 400
  • GET /orders/user/:address?cursor=<valid base64url> → 200, applies cursor WHERE clause
  • GET /orders/user/:address?status=OPENfindMany called with take: 21, no skip
  • POST /orders with non-Stellar userAddress → 400 from Zod before any DB call
  • Any error response contains { error, code, requestId, statusCode } with correct code per error class

Note: All 32 test suites currently fail in CI due to a pre-existing Prisma schema error (ResolutionCandidate missing back-relation on Market) that prevents prisma generate. This blocks the entire test runner and is unrelated to these changes. TypeScript compilation passes cleanly on all modified files.
closes #561

closes #563

closes #564

closes #562

chidinma000 and others added 2 commits June 30, 2026 06:18
…atix-Protocol#562, Vatix-Protocol#564, Vatix-Protocol#563)

- Vatix-Protocol#562: Fix stale offset-pagination tests for GET /orders/user/:address;
  align assertions with cursor-pagination impl (nextCursor, hasNext, take:limit+1);
  add tests for nextCursor generation, invalid cursor (400), and cursor-based next page
- Vatix-Protocol#564: Add `code` field to ErrorResponse DTO (VALIDATION_ERROR, NOT_FOUND,
  UNAUTHORIZED, FORBIDDEN, INTERNAL_ERROR, BAD_REQUEST); covered by new tests
- Vatix-Protocol#563: Harden POST /orders Zod schema — userAddress now validated against
  STELLAR_PUBLIC_KEY_REGEX before any DB call; add zod to dependencies

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Emeka000 Emeka000 changed the title feat: cursor pagination, standardized error DTO, and Zod hardening (#562, #563, #564) feat: cursor pagination, standardized error DTO, and Zod hardening Jun 30, 2026
@Mimah97 Mimah97 merged commit 24ba525 into Vatix-Protocol:dev Jun 30, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants