Skip to content

fix: resolve failing tests and type errors across api and shared packages#50

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2285-1781284244
Open

fix: resolve failing tests and type errors across api and shared packages#50
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2285-1781284244

Conversation

@stooit

@stooit stooit commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the multi-package TypeScript HTTP API (Hono). After this change: 22/22 tests pass and tsc --noEmit is clean.

Bugs fixed

  • Auth middleware (packages/api/src/middleware/auth.ts) — case-sensitivity bug in the public-route allow-list. Hono normalises c.req.method to uppercase, so the lowercase comparison never matched, causing public routes (e.g. POST /users) to wrongly require a token. Now compares against uppercase method names.
  • Shared types (packages/shared/src/types.ts) — field-name inconsistency between packages. The User type field is now consistently username, matching what the API routes and tests expect.
  • Users route (packages/api/src/routes/users.ts) — missing badRequest import caused a runtime failure on the 400 (missing fields) path.
  • Pagination utility (packages/shared/src/utils/pagination.ts) — implemented the paginate stub to satisfy the full test contract (page slice, partial last page, out-of-range page, total/totalPages, page/pageSize).
  • tsconfig — added bun-types (already installed, no new dependency) so bun:test and the process global resolve under tsc.

Verification

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

Notes / assumptions

  • Constraint honoured: no test files modified, no new dependencies added — only the source changes the tests required.
  • Field-name inconsistency was resolved by aligning source to the tests' expectation (username), since tests must not be edited.
  • A code review flagged two latent edge cases not covered by tests (size=0 and negative page in paginate). These were left untouched to respect the "fix only what the tests require" constraint and avoid scope creep.

🤖 Generated with autonomous agent

…ages

- auth middleware: fix case-sensitivity bug in HTTP method allow-list
  (compare against uppercase GET/POST as Hono normalises method names)
- shared types: align User field name to 'username' across both packages
- users route: add missing 'badRequest' import
- pagination: implement the paginate stub per the test contract
- tsconfig: add bun-types and @e2e/shared path alias for clean 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