Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2500-1783873504
Open

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

Conversation

@stooit

@stooit stooit commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and all tsc --noEmit type errors in the multi-package (Hono api + shared) repo. After these changes bun test reports 22 pass / 0 fail and npx tsc --noEmit exits clean.

Changes

  • Pagination (packages/shared/src/utils/pagination.ts) — implemented the previously-stubbed paginate() (it threw not implemented). Correctly computes total, totalPages, page/pageSize, and the page slice; handles empty arrays, out-of-range pages, and partial last pages.
  • Auth middleware (packages/api/src/middleware/auth.ts) — fixed an HTTP-method case-sensitivity bug so the public-route check matches regardless of method casing, making POST /users public (no token required).
  • Users route (packages/api/src/routes/users.ts) — added the missing badRequest import that was causing a runtime failure (and TS2552) on the 400-for-missing-fields path.
  • Shared type (packages/shared/src/types.ts) — aligned the User field name to username for cross-package consistency (resolves TS2561); the field name is now canonical across both packages.
  • tsconfig — added a types entry so bun:test and the process global resolve without installing new dependencies.

Verification

  • bun test → 22 pass, 0 fail
  • npx tsc --noEmit → clean (exit 0)
  • Independent review pass confirmed pagination edge-case math, the auth casing fix, and cross-package field-name consistency.

Assumptions

  • No test files were modified and no dependencies were added, per task constraints.
  • Existing type packages in node_modules were wired up via tsconfig rather than installing anything new.

Constraints honoured

  • No test files modified · no new dependencies · minimal, targeted fixes.

- Implement paginate() in shared (was a throwing stub)
- Fix auth middleware HTTP-method case-sensitivity so POST /users is public
- Add missing badRequest import in users route
- Align shared User type field to 'username' for cross-package consistency
- Add types entry to tsconfig 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