Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2289-1783616287
Open

fix: repair failing tests and type errors across api + shared packages#83
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2289-1783616287

Conversation

@stooit

@stooit stooit commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors so bun test && tsc --noEmit pass cleanly. Bugs spanned both the api and shared packages.

Result: 22 tests pass (0 fail), zero type errors.

Changes

  • Pagination utility (packages/shared/src/utils/pagination.ts): implemented the paginate() stub — page slicing, total/totalPages math, page/pageSize echo-back, and correct handling of out-of-range pages and empty arrays.
  • Auth middleware (packages/api/src/middleware/auth.ts): fixed a case-sensitivity bug in the public-method allow-list. Hono's c.req.method is uppercase (POST), but the allow-list compared against a lowercase literal, so POST /users incorrectly required a token.
  • Shared types (packages/shared/src/types.ts): renamed User.userNameusername to match every call-site in the route handler and the test fixtures.
  • Users route (packages/api/src/routes/users.ts): added the missing badRequest import.
  • tsconfig (tsconfig.json): added bun-types so bun:test and process globals resolve under tsc --noEmit (no new dependency installed — bun-types was already present).

Verification

  • bun test → 22 pass, 0 fail
  • npx tsc --noEmit → no errors
  • No test files modified; no dependencies added.

Assumptions & notes

  • Aligned non-test source to the spelling the tests use (username), since test files must not change.
  • Two out-of-scope latent items intentionally left alone (task = fix only what tests require): paginate() has no guard for size <= 0, and "types": ["bun-types"] suppresses automatic @types/* inclusion — add "node" there if a Node-native ambient type is needed downstream.

…d imports

- Implement paginate() in shared package (page slicing, total/totalPages,
  out-of-range and empty-array handling)
- Fix case-sensitivity bug in auth middleware public-method allow-list so
  POST /users is treated as public
- Rename User.userName -> username in shared types to match call-sites and tests
- Add missing badRequest import in users route handler
- Add bun-types to tsconfig so bun:test/process 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