fix: repair failing tests and type errors across api and shared packages - #121
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#121stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
… paginate - auth: normalise HTTP method casing so public POST route works (was 'post' vs 'POST') - shared: rename User.userName -> username to match API usage and tests - users route: import badRequest (was ReferenceError on the 400 path) - shared: implement paginate() covering the full test contract - tsconfig: add bun-types to resolve process/bun:test globals
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 the full test suite green (22/22 pass) and
tsc --noEmitclean. Four distinct bugs spanning both packages, plus one build-config fix.Changes
packages/api/src/middleware/auth.ts): the public-methods allow-list used lowercase"post", soPOSTnever matched and the route incorrectly demanded a token. Fixed to"POST"and normalised the incoming method with.toUpperCase()to prevent casing regressions. Fixes auth middleware > POST /users is public.packages/shared/src/types.ts): renamedUser.userName→usernameto match API usage and the tests.packages/api/src/routes/users.ts): added the missingbadRequestimport — the invalid-body path threw aReferenceErrorinstead of returning 400. Fixes POST /users > returns 400 for missing fields.packages/shared/src/utils/pagination.ts): implemented thepaginate()stub against the full test contract — 1-indexed pages,totalPages = ceil(total/pageSize)(0 for empty input), out-of-range pages return an empty slice, page/size clamped to ≥1. Fixes all 7 paginate tests.tsconfig.json): added"types": ["bun-types"].bun-typeswas already an installed devDependency but unreferenced, soprocessandbun:testdidn't resolve.Verification
bun test→ 22 pass, 0 failtsc --noEmit→ exit 0, no errorsAssumptions / notes
userName→usernamerename was applied to the type (not the route) because the tests useusername; aligning the other direction would have broken passing tests.POST /usersis now genuinely unauthenticated (intended policy, asserted by tests);paginate()doesn't coerce string page/size args; auth'sBearerprefix stripping and token comparison are pre-existing and untouched.