Skip to content

feat(shared-types): implement shared API response envelopes#205

Merged
therealjhay merged 2 commits into
Betta-Pay:mainfrom
TheBigWealth89:feat/shared-api-envelopes
Jun 30, 2026
Merged

feat(shared-types): implement shared API response envelopes#205
therealjhay merged 2 commits into
Betta-Pay:mainfrom
TheBigWealth89:feat/shared-api-envelopes

Conversation

@TheBigWealth89

@TheBigWealth89 TheBigWealth89 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Closes #107


feat(shared-types): Implement shared API response envelopes

Description

This PR standardizes the API response structure across the BettaPay monorepo by introducing strongly-typed response envelopes. This ensures that all services provide a consistent contract to frontends and API consumers, cleanly delineating successful data payloads from standardized error formats.

Changes Made

  • Shared Types Definitions (shared/types/index.ts):
    • Added ApiResponse<T> to wrap single resource payloads and handle errors using the standard ErrorResponse schema.
    • Added PaginatedResponse<T> to standardize list queries, encapsulating the list within data and appending strict pagination metadata (total, limit, offset, hasMore).
  • Service Type Safety Refactoring:
    • api-gateway: Updated GET /api/merchants/:id to explicitly return Promise<ApiResponse<Merchant>>. Used the existing createErrorResponse() logic to map NOT_FOUND events directly into the { error: ErrorResponse } envelope without changing core business logic. Added missing @bettapay/shared-types dependency.
    • settlement-engine: Updated GET /api/settlements to explicitly return Promise<PaginatedResponse<SettlementRecord>> and structured the list logic to populate the pagination metadata appropriately.
  • Repository Maintenance:
    • Resolved lingering merge conflict markers inside indexer/src/index.ts and addressed a latestLedgerCursor undefined calculation that was disrupting workspace builds.

Type-Safety & Tests

  • All 8 workspace packages successfully compile with pnpm -r type-check
  • Full build script pnpm -r build passes locally
  • All local tests across services continue to pass with zero regressions

@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@TheBigWealth89 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

@therealjhay

Copy link
Copy Markdown
Contributor

Kindly resolve conflict

@TheBigWealth89

Copy link
Copy Markdown
Contributor Author

Kindly resolve conflict

I have resolved all conflict

@therealjhay therealjhay merged commit 74377c4 into Betta-Pay:main Jun 30, 2026
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.

Add shared API response envelope type

2 participants