Skip to content

feat: standard error envelope, OpenAPI generation, cursor pagination, and validation middleware - #1828

Merged
Smartdevs17 merged 1 commit into
Smartdevs17:mainfrom
Gbemi-programmer:feat/api-quality-improvements-1784-1785-1786-1787
Oct 18, 2026
Merged

Smartdevs17 merged 1 commit into
Smartdevs17:mainfrom
Gbemi-programmer:feat/api-quality-improvements-1784-1785-1786-1787

Conversation

@Gbemi-programmer

Copy link
Copy Markdown
Contributor

Closes #1785
Closes #1784
Closes #1787
Closes #1786

Changes

#1785 Standard error envelope

  • DomainError (backend/services/shared/errors.ts) now builds one consistent shape (code, message, statusCode, details, requestId, userMessage, recovery). It still accepts the old calling styles, so existing callers keep working.
  • HTTP status is taken from ERROR_HTTP_STATUS_MAP in apiResponse.ts when only an error code is given.
  • The error codes are documented in docs/ERROR_HANDLING.md.

#1784 OpenAPI generation

  • New scripts/generate-openapi.ts builds spec/openapi.yaml, developer-portal/docs/openapi.json and sdks/generated/endpoints.json from the source schemas.
  • New scripts: openapi:generate and openapi:check. CI runs openapi:check and fails on drift.
  • The spec is published at GET /api/docs/openapi.json, with a Swagger UI at GET /api/docs.

#1787 Cursor pagination

  • List endpoints (plans controller and public API router) use cursor pagination with stable ordering and a bounded default page size.
  • Requests without a cursor still work, so existing clients are unaffected.

#1786 Request validation middleware

  • validationMiddleware.ts checks requests against a schema at the edge and rejects bad input with the standard error envelope (VALIDATION_ERROR plus details for each field).
  • It is exported from backend/shared/middleware and wired into createApiServer. Documented in docs/VALIDATION.md.

Tests

  • New tests: validationMiddleware.test.ts, generateOpenApi.test.ts.
  • errors, apiResponse and pagination suites pass.
  • pnpm run openapi:check reports no drift.

Notes

In backend/services/shared, 20 suites (50 tests) already fail on main. They fail exactly the same way on this branch, so this PR adds no new failures.

@drips-wave

drips-wave Bot commented Oct 18, 2026

Copy link
Copy Markdown

@Gbemi-programmer 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

@Smartdevs17
Smartdevs17 merged commit 2844351 into Smartdevs17:main Oct 18, 2026
2 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

2 participants