Skip to content

fix: repair failing tests and type errors across api and shared packages - #100

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2535-1784944520
Open

fix: repair failing tests and type errors across api and shared packages#100
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2535-1784944520

Conversation

@stooit

@stooit stooit commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and eliminates all tsc --noEmit type errors in the api (Hono) and shared packages. Final state: 22 pass / 0 fail, tsc clean.

Changes

  • packages/shared/src/utils/pagination.ts — Implemented the paginate<T>() stub. Correctly handles partial last page, out-of-range pages (returns empty data), empty arrays, and totalPages calculation (with a zero-size guard).
  • packages/api/src/middleware/auth.ts — Fixed a case-sensitivity bug: the method allow-list used lowercase ('post') while c.req.method returns uppercase ("POST"), so valid POSTs were rejected with 401. Normalised the allow-list to uppercase. No auth bypass introduced.
  • packages/api/src/routes/users.ts — Added the missing badRequest import; aligned the create payload to use username.
  • packages/shared/src/types.ts — Made the User.username field name consistent across both packages (tests expect username).
  • tsconfig.json — Added "types": ["bun-types"] so bun:test and the process global resolve under tsc. No new dependencies added.

Verification

  • bun test → 22 pass, 0 fail (4 files)
  • bunx tsc --noEmit → clean
  • Independent review pass confirmed correctness with no blocking issues.

Constraints honoured

  • No test files modified.
  • No dependencies added.
  • Only the minimal changes required by the tests.

Assumptions

  • The username/userName inconsistency resolved toward username because the (unmodifiable) tests use username.
  • The bun:test / process errors were type-resolution config, not missing packages — resolved via tsconfig types.

- Implement paginate() utility with correct edge-case handling
- Fix auth middleware HTTP method case-sensitivity (uppercase allow-list)
- Add missing badRequest import in users route
- Align User.username field naming between packages
- Configure bun-types in tsconfig so bun:test and process resolve under tsc
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.

1 participant