fix: repair failing tests and type errors across api and shared packages - #146
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#146stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- Implement paginate() stub in shared with finite-input clamping - Rename User.userName -> username in shared types to match API/tests - Import missing badRequest in users route (400 instead of 500) - Fix HTTP-method case bug in auth middleware (POST public) - Add bun-types to tsconfig types so bun:test and process resolve
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 all
tsc --noEmittype errors in the multi-package Hono API repo.bun test→ 22 pass / 0 fail;tsc --noEmitexits clean.Root causes fixed
packages/shared/src/utils/pagination.ts):paginate()threwnot implemented. Implemented per the test contract (out-of-range page → empty data, empty array →total/totalPages: 0). Added finite-input clamping soNaN/Infinitypage/size coerce to sensible defaults (≥1 integers) rather than propagating.packages/shared/src/types.ts):User.userNamerenamed tousernameto match the API routes and tests (tests are the source of truth and useusername). Resolved theTS2561errors.packages/api/src/routes/users.ts):badRequestwas called but never imported →ReferenceError→ 500 instead of 400. Added to the existing../lib/errorsimport.packages/api/src/middleware/auth.ts): public-methods list had"post"(lowercase);Request.methodis always uppercase, so POST /users wrongly required a token (401). Fixed to"POST".tsconfig.json): added"types": ["bun-types"]sobun:testandprocessresolve (both already innode_modules, no new deps).Constraints respected
bun-typesvia tsconfig).libtsconfig entry flagged in review was removed to keep to "fix only what tests require".Assumptions
username(per tests), so the shared type was the incorrect side, not the routes.auth.test.tsand the middleware policy comment. Note for follow-up (out of scope): this permits unauthenticated writes to/usersand/posts— worth revisiting for a production posture, but mandated by the tests here.Verification
bun test && npx tsc --noEmitverified green after every change.