Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-4746-1782664439
Open

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

Conversation

@stooit

@stooit stooit commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests (now 22/22 passing) and all tsc --noEmit type errors across the api and shared packages. Bugs spanned both packages as anticipated.

Fixes

  • Auth middleware (packages/api/src/middleware/auth.ts): the public-method allow-list contained lowercase "post", but Hono normalises HTTP methods to uppercase per RFC 7231, so POST /users never matched and was rejected with 401. Corrected to "POST".
  • Shared types (packages/shared/src/types.ts): User.userName was inconsistent with the db layer, route handlers, and test expectations, all of which use username. Reconciled the type to username so the field name is consistent across both packages.
  • Route handler (packages/api/src/routes/users.ts): added the missing badRequest import that caused a runtime/type failure.
  • Pagination utility (packages/shared/src/utils/pagination.ts): implemented the previously-stubbed function — 1-indexed pages, correct partial last page, empty input (totalPages: 0, no NaN), and out-of-range pages (returns empty data without crashing).
  • tsconfig (tsconfig.json): added bun-types and the @e2e/shared path alias to resolve bun:test, the process global, and cross-package imports. No new dependencies added.

Verification

  • bun test -> 22 pass, 0 fail
  • tsc --noEmit -> clean (exit 0)

Constraints honoured

  • No test files modified
  • No new dependencies added
  • Changes are minimal and limited to what the tests require

Assumptions

  • Where a test and source disagreed on a field name, the test was treated as authoritative (username over userName).
  • The bun-types / @e2e/shared tsconfig entries rely on packages already present in node_modules; no additions to package.json or the lockfile were made.

- auth middleware: correct public-method allow-list to uppercase 'POST' so
  POST /users is not incorrectly rejected with 401 (Hono normalises methods)
- shared types: reconcile User.userName -> username to match db layer,
  route handlers, and test expectations across both packages
- routes/users: add missing badRequest import
- shared utils: implement pagination utility (1-indexed page, partial last
  page, empty input, out-of-range page all handled)
- tsconfig: add bun-types and @e2e/shared path alias to resolve bun:test,
  process global, and cross-package imports
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