Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2474-1783786975
Open

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

Conversation

@stooit

@stooit stooit commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and eliminates all TypeScript type errors in the monorepo. After these changes bun test reports 22 pass / 0 fail and npx tsc --noEmit is clean (exit 0).

Changes

  • Auth middleware (packages/api/src/middleware/auth.ts): fixed a case-sensitivity bug — the public-methods allow-list used lowercase 'post' but Hono's c.req.method is uppercase, so POST /users was incorrectly requiring a token. Also fixes the process type error via the tsconfig change below.
  • Shared types (packages/shared/src/types.ts): renamed the User field userNameusername to match the canonical name used by the tests and the API routes (cross-package inconsistency).
  • Users route (packages/api/src/routes/users.ts): added the missing badRequest import from ../lib/errors (was used but not imported, causing a runtime + type failure). Removed a now-stale // BUG: comment.
  • Pagination utility (packages/shared/src/utils/pagination.ts): implemented the previously-stubbed paginate() per the test contract — computes total, totalPages (0 when empty), slices the correct page, and returns { data, page, pageSize, total, totalPages }. Out-of-range pages yield an empty data array.
  • tsconfig (tsconfig.json): added typeRoots + types (node, bun-types) so bun:test and process resolve. Packages were already installed; no new dependencies added.

Verification

  • bun test → 22 pass, 0 fail (37 assertions, 4 files)
  • npx tsc --noEmit → no errors

Assumptions

  • Test files are canonical and were not modified; source was made to conform to the tests.
  • username (not userName) is the canonical field name, as used by the tests.
  • paginate() does not clamp negative/zero page sizes or negative pages — these cases are outside the test contract and the task scope ("fix only what the tests require"). A follow-up could add input guards if desired.

…ages

- auth middleware: fix case-sensitivity bug on public HTTP method (POST)
- shared types: rename User.userName to username for cross-package consistency
- users route: import missing badRequest error helper
- pagination: implement paginate() utility per test contract
- tsconfig: add typeRoots/types so bun:test and process resolve
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