Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2430-1783096715
Open

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

Conversation

@stooit

@stooit stooit commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the Bun + Hono monorepo. All 22 tests pass and tsc --noEmit is clean.

Changes

  • shared: implement paginate<T>() — was a stub throwing "not implemented". Now slices by (page-1)*size, computes total/totalPages, and returns { data, page, pageSize, total, totalPages }. Handles empty arrays, partial last pages, and out-of-range pages.
  • shared: rename User.userNameusername — the field name was inconsistent between packages; aligned to what the (unmodifiable) tests expect, updating all handler/db usages.
  • api: add missing badRequest import in routes/users.ts (was "Cannot find name 'badRequest'").
  • api: fix auth middleware HTTP-method case bug — public-method comparison used lowercase 'post' where Hono's c.req.method returns uppercase 'POST', so POST /users was incorrectly requiring a token.
  • tsconfig: scope types to ["bun-types"] — resolves bun:test / process type errors under tsc. bun-types is an existing devDependency; no new dependencies added.

Verification

  • bun test → 22 pass, 0 fail
  • bunx tsc --noEmit → no errors

Assumptions

  • The tests are the source of truth for the correct username field name.
  • Per the "fix only what the tests require" constraint, non-blocking review suggestions (a size <= 0 guard in paginate, echoing out-of-range page, a restored policy comment) were intentionally left out of scope — no test exercises those paths and no current caller invokes paginate.

Constraints honoured

  • No test files modified
  • No new dependencies added

- implement paginate() utility in shared package (was a stub)
- rename User.userName -> username for cross-package consistency
- add missing badRequest import in users route handler
- fix auth middleware HTTP-method case comparison ('post' -> 'POST')
- scope tsconfig types to bun-types to resolve tsc errors
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