Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2471-1785001652
Open

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

Conversation

@stooit

@stooit stooit commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the repository. bun test now reports 22 pass / 0 fail and bunx tsc --noEmit is clean.

Changes

  • packages/shared/src/utils/pagination.ts — implemented the previously-stubbed paginate<T>(). Handles all edge cases: empty array (totalPages: 0, no NaN), out-of-range page (empty slice), partial last page, and correct total/totalPages/page/pageSize fields.
  • packages/api/src/middleware/auth.ts — fixed a case-sensitivity bug in the HTTP-method comparison so POST /users is correctly matched as a public route (no token required).
  • packages/api/src/routes/users.ts — added the missing badRequest response-helper import that caused a runtime failure / type error, fixing the "returns 400 for missing fields" test.
  • packages/shared/src/types.ts — renamed User.userNameusername to match what the routes and tests use. Updated all non-test usages.
  • tsconfig.json — added "types": ["bun-types"] so tsc resolves bun:test and process for the type-check.

Verification

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

Constraints honoured

  • No test files modified.
  • No new dependencies added.
  • Independent code review passed clean.

Assumptions

  • The username field (not userName) is canonical, since tests and route handlers use it and the type comment flagged the mismatch as a bug.
  • bun-types was already available in the workspace; the tsconfig change only brings it into scope for type-checking.

…ages

- implement paginate() in shared with correct edge-case handling
- fix case-sensitive HTTP method comparison in auth middleware (POST)
- add missing badRequest import in users route
- rename User.userName -> username to match tests and routes
- add bun-types to tsconfig so tsc resolves bun:test and process
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