Skip to content

Fix 920 - #1027

Open
fahatadam wants to merge 2 commits into
StellarDevHub:mainfrom
fahatadam:fix-920
Open

Fix 920#1027
fahatadam wants to merge 2 commits into
StellarDevHub:mainfrom
fahatadam:fix-920

Conversation

@fahatadam

Copy link
Copy Markdown

PR Title:
fix: type and test backend i18n middleware and localized error responses

Description:

What was done:

  • Removed // @ts-nocheck suppressions from backend/src/index.ts and backend/src/routes/index.ts to un-suppress the i18n routing path and enforce type checking.
  • Updated backend/src/middleware/i18n.ts to robustly parse req.headers['accept-language'] arrays, explicitly enforcing safe type handling for the locale negotiation.
  • Created and exported a LocalizedError class in backend/src/middleware/errorHandler.ts to create a strictly typed contract for translating backend errors.
  • Updated the global errorHandler to intercept LocalizedError instances, automatically fetching the localized message with req.t(err.key), while safely falling back to a generic 500 error for standard native errors.
  • Added comprehensive Jest tests for i18n header fallback logic (i18n.test.ts) and global error handler fallback safety (errorHandler.test.ts).

Why it was done:
To establish a typed and testable contract for locale selection and safe translated errors without suppressing type safety on the backend. This guarantees deterministic locale negotiation and prevents sensitive error information from leaking out during runtime exceptions.

How it was verified:

  • Verified by adding targeted unit tests that cover header negotiations, unsupported locales, array edge-cases, and error localization fallback flows.
  • Verified TypeScript compilation constraints are preserved successfully after the removal of the @ts-nocheck directives.

Closes #920

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

@fahatadam is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

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

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.

[Backend] Type and test backend i18n middleware and localized error responses

1 participant