Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2419-1785040083
Open

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

Conversation

@stooit

@stooit stooit commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and TypeScript errors in the repo. Final state: 22 pass / 0 fail, tsc --noEmit clean.

Changes

  • packages/shared/src/utils/pagination.ts — implemented the paginate() stub. Returns the correct page slice with total, totalPages (Math.ceil), page, pageSize. Handles empty arrays, out-of-range pages (returns empty data), partial last pages, and guards size=0.
  • packages/api/src/middleware/auth.ts — fixed the HTTP-method case-sensitivity bug so POST /users is treated as public. DELETE/PUT/PATCH without a token still return 401.
  • packages/api/src/routes/users.ts — imported the missing badRequest helper and aligned field usage to username.
  • packages/shared/src/types.ts — renamed User.userNameusername for cross-package consistency (tests use username).
  • tsconfig.json — added bun-types to resolve process / bun:test. Already a devDependency; no new dependencies added.

Constraints honoured

  • No test files modified.
  • No dependencies added (only wired up already-installed bun-types).

Verification

  • bun test → 22 pass / 0 fail
  • npx tsc --noEmit → exit 0
  • Independent review pass confirmed correctness.

Assumptions

  • Canonical field name is username (matching tests); the outlier userName was renamed.

- implement paginate() utility in shared package (edge cases: empty, out-of-range, partial last page)
- fix auth middleware HTTP method case-sensitivity so POST /users is public
- import badRequest and align username field in users route
- rename User.userName -> username in shared types for cross-package consistency
- wire already-installed bun-types into tsconfig for process/bun:test resolution
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