Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2419-1781909572
Open

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

Conversation

@stooit

@stooit stooit commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes bun test fully green (22/22) and npx tsc --noEmit clean. Bugs spanned both the api and shared packages.

Fixes

  • Auth middleware (packages/api/src/middleware/auth.ts): the public-route check compared the request method against lowercase 'post', but Hono surfaces HTTP methods uppercase — so POST /users was never recognised as public. Changed to 'POST'.
  • Users route (packages/api/src/routes/users.ts): badRequest was used but not imported. Added it to the existing import from ../lib/errors.
  • Shared User type (packages/shared/src/types.ts): field renamed userNameusername to match the API contract and test expectations (cross-package field-name inconsistency).
  • Pagination util (packages/shared/src/utils/pagination.ts): implemented the paginate() stub (page slice, total, totalPages, pageSize) per the test contract; handles empty arrays and out-of-range pages.
  • tsconfig (tsconfig.json): added bun-types to compilerOptions.types (already installed) so bun:test globals and process resolve under tsc. No new dependencies added.

Verification

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

Assumptions

  • The canonical field name is username (lowercase), since the tests use it and test files must not be edited.
  • Type-only environment errors (process, bun:test) were resolved via tsconfig rather than touching tests or adding deps, since bun-types was already present in node_modules.

Constraints honoured

No test files modified, no dependencies added.

- auth middleware: compare HTTP method against uppercase 'POST' (Hono surfaces methods uppercase) so POST /users is correctly treated as public
- users route: import missing 'badRequest' helper from ../lib/errors
- shared User type: rename field userName -> username to match the API contract and tests
- pagination util: implement paginate() (slice/total/totalPages) replacing the not-implemented stub
- tsconfig: add bun-types to compilerOptions.types so bun:test globals 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