Conversation
Implements the paginate() stub in shared, fixes the lowercase 'post' in the auth allow-list that made POST require a token, adds the missing badRequest import in the users route, and renames User.userName to username to match API and test usage. Adds bun-types to tsconfig types so bun:test and the process global 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 (9 → 0) and type errors (14 → 0) across the
apiandsharedpackages.bun test(22 pass) andnpx tsc --noEmit(exit 0) are both green. No test files were modified and no dependencies were added.Changes
packages/shared/src/utils/pagination.ts— implemented the stubbedpaginate(). Slices from(page-1)*size, so out-of-range pages yield[];totalPages = Math.ceil(total/size)(0 for empty). Guardsstart < 0(a negativeslicestart would otherwise return items from the end of the array) andsize <= 0(division-by-zero).packages/shared/src/types.ts— renamedUser.userName→username. Both packages' tests construct users withusername, so the type was the inconsistency.packages/api/src/middleware/auth.ts— public-methods allow-list had"post"(lowercase);c.req.methodis always uppercase per RFC 7231, soPOSTnever matched and fell through to token validation (401). Changed to"POST".packages/api/src/routes/users.ts— added the missingbadRequestimport; it was referenced in the missing-fields branch, throwing aReferenceError(500 instead of the expected 400).tsconfig.json— added"types": ["bun-types"]sobun:testand theprocessglobal resolve.bun-typeswas already a devDependency; nothing new installed.Verification
```
bun test → 22 pass, 0 fail
npx tsc --noEmit → exit 0
```
Assumptions & scope notes
userName/usernamefield), the source was fixed, not the test.page/sizenormalisation inpaginate— which no test exercises and no production caller passes; left out to avoid scope creep.POST /usersis intentional, test-enforced inauth.test.tswith an explicit comment. Noted only for awareness: unauthenticated writes would be an access-control concern in a real service.🤖 Generated autonomously.