fix: repair failing tests and type errors across api and shared packages - #142
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#142stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- auth middleware: fix case-sensitivity bug (lowercase 'post' -> 'POST') so POST routes are correctly treated as public; normalise method case - routes/users: add missing badRequest import (was throwing ReferenceError -> 500 instead of 400 on invalid input) - shared types: rename User.userName -> username for consistency with route handlers and tests - shared pagination: implement paginate() to satisfy the full test contract - tsconfig: register already-installed bun-types for ambient process/bun:test All 22 tests pass and tsc --noEmit is clean. No test files or dependencies changed.
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 in the repository. Final state: 22/22 tests pass,
tsc --noEmitclean (0 errors).Bugs fixed
packages/api/src/middleware/auth.ts): the public-method allow-list used lowercase"post", soPOSTrequests (always uppercase per RFC 7231) were never matched and incorrectly required a token. Changed to"POST"and added.toUpperCase()normalisation.packages/api/src/routes/users.ts):badRequestwas called but never imported, throwing aReferenceErrorand returning 500 instead of 400 on invalid input. Added it to the existing import from../lib/errors.packages/shared/src/types.ts):User.userNamedid not match theusernamefield used by the route handlers and tests. Renamed the type field tousername.packages/shared/src/utils/pagination.ts): implementedpaginate<T>()to satisfy the full test contract — correct page slice, second/partial pages,total/totalPages,page/pageSize, out-of-range returns empty data, and empty-array handling.tsconfig.json): registered the already-installedbun-typessoprocessandbun:testresolve undertsc.Verification
bun test→ 22 pass, 0 failbunx tsc --noEmit→ exit 0, no errorsAssumptions & notes
username/userNamemismatch was resolved by changing the shared type (not the tests), since tests and route code both useusernameand test files must not be modified.bun-typeswas already present innode_modules.