fix: resolve failing tests and type errors across api and shared packages#53
Open
stooit wants to merge 1 commit into
Open
fix: resolve failing tests and type errors across api and shared packages#53stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
…ages - auth middleware: fix case-sensitive HTTP method comparison (post -> POST) - shared types: rename User.userName -> username for cross-package consistency - users route: add missing badRequest import from lib/errors - pagination: implement paginate() stub (slice, total, totalPages, page, pageSize) - tsconfig: add typeRoots so process/bun:test resolve under tsc --noEmit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all 9 failing tests and clears all
tsc --noEmittype errors in this multi-package Hono API.bun testis now 22 pass / 0 fail andnpx tsc --noEmitexits clean. No test files were modified and no dependencies were added.Root causes & fixes
packages/api/src/middleware/auth.ts) — the public-methods allow-list compared'post'(lowercase) against Hono's uppercasec.req.method, so the case-sensitiveincludes()never matched andPOST /userswas incorrectly treated as protected. Fixed'post'→'POST'.packages/shared/src/types.ts) —User.userNamerenamed tousernameto match what the (frozen) tests and thedb.users.createcontract expect. No other source files referenced the old name.packages/api/src/routes/users.ts) —badRequestwas used but not imported; added it to the existing import from../lib/errors.packages/shared/src/utils/pagination.ts) — implemented thepaginate()stub: correct page slice,total,totalPages(empty-array → 0),page, andpageSize. Verified against all 7 pagination tests including out-of-range and empty-array cases.tsconfig.json— addedtypeRootssoprocess(@types/node) and thebun:testmodule resolve undertsc --noEmit, without adding dependencies. Uses stable, non-version-pinned paths so it won't break on dependency bumps in CI.Verification
bun test→ 22 pass / 0 failnpx tsc --noEmit→ exit 0Assumptions
POST /users(registration) is intended to be public — consistent with the existing allow-list intent and the testPOST /users is public (no token required).usernameis the canonical field name (tests are the source of truth and could not be edited).