fix: repair failing tests and type errors across api + shared packages#83
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api + shared packages#83stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
…d imports - Implement paginate() in shared package (page slicing, total/totalPages, out-of-range and empty-array handling) - Fix case-sensitivity bug in auth middleware public-method allow-list so POST /users is treated as public - Rename User.userName -> username in shared types to match call-sites and tests - Add missing badRequest import in users route handler - Add bun-types to tsconfig so bun:test/process globals 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
Fixes all failing tests and type errors so
bun test && tsc --noEmitpass cleanly. Bugs spanned both theapiandsharedpackages.Result: 22 tests pass (0 fail), zero type errors.
Changes
packages/shared/src/utils/pagination.ts): implemented thepaginate()stub — page slicing,total/totalPagesmath,page/pageSizeecho-back, and correct handling of out-of-range pages and empty arrays.packages/api/src/middleware/auth.ts): fixed a case-sensitivity bug in the public-method allow-list. Hono'sc.req.methodis uppercase (POST), but the allow-list compared against a lowercase literal, soPOST /usersincorrectly required a token.packages/shared/src/types.ts): renamedUser.userName→usernameto match every call-site in the route handler and the test fixtures.packages/api/src/routes/users.ts): added the missingbadRequestimport.tsconfig.json): addedbun-typessobun:testandprocessglobals resolve undertsc --noEmit(no new dependency installed —bun-typeswas already present).Verification
bun test→ 22 pass, 0 failnpx tsc --noEmit→ no errorsAssumptions & notes
username), since test files must not change.paginate()has no guard forsize <= 0, and"types": ["bun-types"]suppresses automatic@types/*inclusion — add"node"there if a Node-native ambient type is needed downstream.