Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2442-1782694640
Open

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

Conversation

@stooit

@stooit stooit commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and TypeScript errors so that bun test && bunx tsc --noEmit passes cleanly (22 pass, 0 fail; 0 type errors). Bugs spanned both the api and shared packages. No test files were modified and no dependencies were added.

Fixes

  • Pagination utility (packages/shared/src/utils/pagination.ts): implemented the paginate() stub per the PaginatedResponse contract — data slice, page, pageSize, total, totalPages, with correct handling of empty arrays and out-of-range pages.
  • Shared types (packages/shared/src/types.ts): renamed the User.userName field to username to resolve the cross-package inconsistency (api routes and tests expect username).
  • Auth middleware (packages/api/src/middleware/auth.ts): fixed a case-sensitivity bug — the public-route allow-list used lowercase "post", which never matched Hono's uppercase c.req.method, so POST /users was incorrectly requiring a token.
  • Users route (packages/api/src/routes/users.ts): added the missing badRequest import from ../lib/errors; the missing symbol was throwing a ReferenceError (HTTP 500) instead of returning the intended 400 for missing fields.
  • tsconfig (tsconfig.json): added "types": ["bun-types"] to resolve bun:test and process global type-resolution errors (bun-types was already installed; @types/node was intentionally not added).
  • Removed now-stale TODO/BUG comments describing the bugs that were fixed.

Verification

  • bun test -> 22 pass, 0 fail (37 assertions, 4 files)
  • bunx tsc --noEmit -> 0 errors

Assumptions

  • The canonical User field name is username (lowercase), since the unmodifiable test files and api route handlers use it; the shared type was the outlier.
  • The size = 0 pagination edge case is left unguarded as no test or caller exercises it and adding behavior beyond the test contract would be scope creep.

- implement paginate() utility per the PaginatedResponse contract
- rename User.userName field to username for cross-package consistency
- fix auth middleware HTTP-method casing so POST /users is public
- import badRequest in users route (400 instead of 500 on bad input)
- add bun-types to tsconfig types to resolve bun:test/process globals
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