Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2411-1783443340
Open

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

Conversation

@stooit

@stooit stooit commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the multi-package repo. bun test is now 22/22 green and bunx tsc --noEmit reports zero errors.

Changes

  • packages/shared/src/utils/pagination.ts — implemented paginate() (was a throw new Error("not implemented") stub). Handles empty arrays, out-of-range pages, and partial last pages; returns data, page, pageSize, total, totalPages.
  • packages/api/src/middleware/auth.ts — fixed a case-sensitivity bug where the public-methods list contained "post" (lowercase). Hono's c.req.method is always uppercase, so POST /users was incorrectly treated as requiring a token. Changed to "POST". Also resolved the process type error via tsconfig wiring.
  • packages/api/src/routes/users.ts — added the missing badRequest import that caused a runtime failure on the 400-for-missing-fields path; updated field usage to username.
  • packages/shared/src/types.ts — renamed User.userNameusername to match both the tests and the route handler (the type was the outlier causing the cross-package inconsistency).
  • tsconfig.json — wired in the already-installed bun-types so bun:test and Bun globals resolve under tsc (no new dependencies added).

Verification

  • bun test → 22 pass, 0 fail
  • bunx tsc --noEmit → exit 0, no errors

Assumptions

  • Field naming standardised on username because the test files — which must not be modified — use username.
  • No test files touched, no dependencies added; changes are minimal and scoped to what the tests require.
  • Negative-page input to paginate() is out of scope (not reachable via any route, not exercised by tests).

- Implement paginate() utility (was an unimplemented stub)
- Fix auth middleware case-sensitivity bug ("post" -> "POST") that
  incorrectly rejected public POST /users requests
- Add missing badRequest import / usage in users route handler
- Align shared User type field userName -> username to match tests
  and route handler
- Wire bun-types into tsconfig so bun globals 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