Conversation
…ld name - implement paginate() per shared/test/pagination.test.ts contract - auth: 'post' -> 'POST' so POST is matched as public (HTTP methods are uppercase) - users route: import badRequest from lib/errors - shared types: userName -> username to match API and test usage - tsconfig: add types:["bun-types"] to resolve bun:test and process
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 14
tsc --noEmiterrors across theapiandsharedpackages. Root cause was four independent seeded bugs plus one tsconfig gap.Changes
packages/shared/src/utils/pagination.ts— implementedpaginate()(was a throwing stub).total = items.length,totalPages = Math.ceil(total / size),start = (page - 1) * size,data = items.slice(start, start + size).slicenaturally yields[]for out-of-range pages and the short final page;Math.ceil(0/size) === 0givestotalPages: 0for the empty-array case.packages/api/src/middleware/auth.ts— case-sensitivity bug: public-methods allow-list had"post"(lowercase); HTTP methods are uppercase (RFC 7231), soPOST /userswas wrongly requiring a token. Changed to"POST".packages/api/src/routes/users.ts— added missingbadRequestimport from../lib/errors(was aReferenceErrorat runtime on invalid POST bodies).packages/shared/src/types.ts—User.userName→usernameto match API usage and test expectations (field-name inconsistency between packages). The rename was the correct direction because three of the four type-error sites were in test files, which must not be modified.tsconfig.json— added"types": ["bun-types"]to resolvebun:test(TS2307) andprocess(TS2580) errors in one key. No dependency added —bun-types(and transitive@types/node) were already on disk.Verification
bun test-> 22 pass, 0 fail (was 13 pass / 9 fail)tsc --noEmit-> 0 errors, exit 0 (was 14 errors)Constraints honoured
package.jsonchange. Only the five source/config files above were touched.Assumptions
username(lowercase), since test files reference it and cannot be edited.POST /usersbeing public is pre-existing intended behaviour of this test corpus; the auth fix restores documented behaviour rather than widening access.