Conversation
Rename User.userName to username to match API and test usage, add the missing badRequest import, fix the uppercase POST method check in auth middleware, implement paginate(), and load bun-types in tsconfig.
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 repo.
bun testnow reports 22 pass / 0 fail (was 13 pass / 9 fail) andbunx tsc --noEmitis clean (was 14 errors).Changes
packages/shared/src/types.tsUser.userName→usernameto match the field name the API routes and tests actually use (tests are the source of truth).packages/api/src/middleware/auth.ts"post"(lowercase) butc.req.methodis uppercase per RFC 9110, soPOST /userswas never treated as public. Changed to["GET", "POST"].packages/api/src/routes/users.tsbadRequestimport from../lib/errors(was aReferenceErrorsurfacing as a 500 instead of the expected 400 on missing fields).packages/shared/src/utils/pagination.tspaginate()stub per the contract exercised bypagination.test.ts: 1-indexed pages, echoespage/pageSize, emptydatafor out-of-range pages,totalPages === 0for empty input, partial last page handled.tsconfig.json"types": ["bun-types"]to load the already-installedbun-types(suppliesbun:testand, transitively, theprocessglobal). No new dependencies.Assumptions
username(notuserName) — derived from the test files, which cannot be modified.POST /usersis intentionally public (pinned byauth.test.ts). Left as-is. Note: an unauthenticated write endpoint would warrant authentication + rate limiting before reaching a real/government workload; acceptable here as an e2e fixture.Constraints honoured
package.jsonuntouched).Verification
```
bun test → 22 pass / 0 fail
bunx tsc --noEmit → 0 errors
```