Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2476-1782150016
Open

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

Conversation

@stooit

@stooit stooit commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the multi-package TypeScript HTTP API repo. After this change: 22/22 tests pass and tsc --noEmit reports zero errors.

Root causes fixed

  1. Pagination unimplementedpackages/shared/src/utils/pagination.ts was a stub throwing not implemented. Implemented paginate<T>() with 1-based paging: correct page slice, total, totalPages (ceil(total/size), 0 for empty), partial last page, and empty data for out-of-range pages / empty input.
  2. Auth middleware case-sensitivity bugpackages/api/src/middleware/auth.ts listed "post" (lowercase) in the public-methods allow-list, so POST /users (uppercase per RFC 7231) incorrectly required a token. Fixed to "POST". Protected methods still fall through to the token check — no auth bypass introduced.
  3. Missing importpackages/api/src/routes/users.ts called badRequest without importing it (ReferenceError). Added the import.
  4. Shared type field-name inconsistency — API code used userName while the shared User type and tests use username. Aligned the API package to username.
  5. Type-config errorstsc could not resolve bun:test, the process global, or Bun test globals. Wired bun-types into tsconfig. No source logic affected.

Verification

  • bun test → 22 pass, 0 fail
  • npx tsc --noEmit → clean (exit 0)
  • Independent review pass: APPROVE.

Constraints honored

  • No test files modified.
  • No new dependencies added (used already-present bun-types).
  • Fixed only what the tests required.

- Implement paginate() in shared (was a not-implemented stub)
- Fix auth middleware public-method case sensitivity (post -> POST)
- Add missing badRequest import in users route handler
- Align User field name (userName -> username) across api package
- Wire bun-types into tsconfig so tsc resolves bun:test and 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