fix: repair failing tests and type errors across api and shared packages#78
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#78stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- implement paginate() stub in shared with full contract (slicing, totals, clamping) - fix auth middleware public-method check to use uppercase HTTP method (POST) - rename User.userName to username in shared types to match routes and tests - add missing badRequest import in users route handler - add bun-types to tsconfig types so process and bun:test globals 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 failing tests and eliminates all
tsc --noEmiterrors in this multi-package Hono API repo. Bugs spanned both theapiandsharedpackages.Result:
bun test→ 22 pass / 0 fail (4 files);bunx tsc --noEmit→ 0 errors.Fixes
packages/shared/src/utils/pagination.ts) — implemented thepaginate()stub (wasthrow new Error("not implemented")) to satisfy the full test contract: page slicing,total,totalPages(0 when empty),page/pageSizefields, and clamping for out-of-range pages.packages/api/src/middleware/auth.ts) — case-sensitivity bug: public-methods list used"post"but HTTP methods compare as uppercase, soPOST /userswas not treated as public. Changed to"POST".packages/shared/src/types.ts) — renamedUser.userName→usernameto match the route handlers, DB usage, and test expectations.packages/api/src/routes/users.ts) — added the missingbadRequestimport from../lib/errorsthat caused a runtime failure on the 400/missing-fields path.tsconfig.json— added"types": ["bun-types"](already a devDependency) so theprocessglobal andbun:testmodule resolve for tsc.Constraints honoured
bun-typeswas already present).Assumptions
username(lowercase) field name is canonical, since the route handlers, DB layer, and tests all use it — only the shared type diverged.bun:test/processwere resolved via tsconfigtypesrather than editing tests, per the "do not modify tests" constraint.Verification
Reviewed by the
reviewsubagent (approved, no issues) and independently confirmed bothbun testandbunx tsc --noEmitpass locally.