Standardize api - #564
Merged
Merged
Conversation
MaryammAli
approved these changes
Aug 22, 2026
MaryammAli
left a comment
Contributor
There was a problem hiding this comment.
LGTM
a job well done Dev
this issue was implemented in a short period of time
keep up the good work
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All related tests pass (79/79). Here's a summary of everything delivered for Issue closes #562 :
Summary of Changes
New Files
src/common/errors/error-envelope.ts — Shared ErrorEnvelope, ValidationErrorField, and ErrorCode enum. This is the single source of truth for the API error contract that clients can import for type safety.
src/common/errors/index.ts — Barrel export for the error types.
test/health.e2e-spec.ts — 18 e2e tests covering all error contract acceptance criteria:
Envelope shape contract (success=false, code, message)
Business error contract (domain codes preserved)
404 error contract
Unhandled exception contract (production vs dev sanitization)
Correlation ID contract (echo, auto-generate, consistency)
Rate-limit and domain error shape contracts (static documentation)
Response headers contract
Modified Files
src/common/filters/global-http-exception.filter.ts — Replaced inline ErrorResponseBody type with shared ErrorEnvelope. Uses ErrorCode enum for stable codes. Re-exports types for downstream consumers.
src/common/utils/validation-error.mapper.ts — Uses shared ValidationErrorField type.
src/main.ts — Uses ErrorCode.VALIDATION_ERROR enum instead of raw string.
test/smoke.e2e-spec.ts and test/app.e2e-spec.ts — Updated to use ErrorCode enum.
jest.config.ts and jest.e2e.config.ts — Fixed moduleFileExtensions order (ts before js) to prevent stale .js build artifacts from shadowing .ts sources in test resolution.
Verification
✅ TypeScript: Zero new type errors (all 51 errors are pre-existing in unrelated modules)
✅ E2E tests: 18/18 pass in health.e2e-spec.ts
✅ Unit tests: 889 pass (29 failures all pre-existing in unrelated modules)
✅ CI-compatible: All changes follow existing conventions and test patterns