Conversation
- Implement stubbed paginate<T> in shared/utils with edge-case guards - Rename User.userName -> username to match API usage and tests - Add missing badRequest import in users route - Fix case-sensitive HTTP method matching in auth middleware - Configure tsconfig types (bun-types) and narrow lib to ES2022 22/22 tests pass, tsc --noEmit clean.
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
Repairs all failing tests and type errors in the Bun + Hono TypeScript multi-package repo. Baseline was 9 failing tests + 14
tscerrors; now 22/22 tests pass andtsc --noEmitis clean (0 errors). No test files were modified and no dependencies were added.Changes
packages/shared/src/utils/pagination.ts— implemented the previously-stubbedpaginate<T>. Slices(page-1)*size; setstotal = items.lengthandtotalPages = Math.ceil(total/pageSize)(yields0for empty array as the test requires). Page/size are clamped to>= 1and floored with finite-number guards so0/negative/NaN/fractional inputs can't produce a negative slice index or divide-by-zero. Fixes 7paginatetest failures.packages/shared/src/types.ts— renamedUser.userName→usernameto match API usage and the tests (README confirmed this direction). Clears 5TS2561errors.packages/api/src/routes/users.ts— added the missingbadRequestimport from../lib/errors, fixingTS2552and the runtimeReferenceErroronPOST /userswith missing fields.packages/api/src/middleware/auth.ts— fixed a case-sensitivity bug in public-route HTTP method matching (["GET","post"]→["GET","POST"]and compare againstmethod.toUpperCase()). Fixes thePOST /users is publictest.tsconfig.json— added"types": ["bun-types"](already an installed devDependency) soprocessandbun:testresolve, and set"lib": ["ES2022"]. Resolves the remainingTS2580/TS2307errors.Verification
Review notes / assumptions
libnarrowed toES2022(server-only, no DOM): the defaultDOMlib masked typos of browser globals in this server-only codebase; narrowing makes those error correctly while keeping bun/server globals resolving. Iftargetis bumped later, bumplibin step.usernamerename direction: tests and README use lowercaseusername; onlytypes.tsuseduserName. Since test files must not change, source was aligned tousername.requireFieldsinvalidate.ts;paginatehas no route consumer yet. None affect the gates.