fix: repair failing tests and type errors across api and shared packages#65
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#65stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- auth middleware: compare HTTP method against uppercase 'POST' (Hono surfaces methods uppercase) so POST /users is correctly treated as public - users route: import missing 'badRequest' helper from ../lib/errors - shared User type: rename field userName -> username to match the API contract and tests - pagination util: implement paginate() (slice/total/totalPages) replacing the not-implemented stub - tsconfig: add bun-types to compilerOptions.types so bun:test globals and process resolve under tsc
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
Makes
bun testfully green (22/22) andnpx tsc --noEmitclean. Bugs spanned both theapiandsharedpackages.Fixes
packages/api/src/middleware/auth.ts): the public-route check compared the request method against lowercase'post', but Hono surfaces HTTP methods uppercase — soPOST /userswas never recognised as public. Changed to'POST'.packages/api/src/routes/users.ts):badRequestwas used but not imported. Added it to the existing import from../lib/errors.Usertype (packages/shared/src/types.ts): field renameduserName→usernameto match the API contract and test expectations (cross-package field-name inconsistency).packages/shared/src/utils/pagination.ts): implemented thepaginate()stub (page slice,total,totalPages,pageSize) per the test contract; handles empty arrays and out-of-range pages.tsconfig.json): addedbun-typestocompilerOptions.types(already installed) sobun:testglobals andprocessresolve undertsc. No new dependencies added.Verification
bun test→ 22 pass, 0 failnpx tsc --noEmit→ clean (exit 0)Assumptions
username(lowercase), since the tests use it and test files must not be edited.process,bun:test) were resolved via tsconfig rather than touching tests or adding deps, sincebun-typeswas already present innode_modules.Constraints honoured
No test files modified, no dependencies added.