fix: repair failing tests and type errors across api and shared packages - #115
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#115stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- shared: implement paginate() utility (was a throwing stub) - shared: rename User.userName -> username to match route and tests - api: import badRequest in users route (fixes ReferenceError on POST /users) - api: normalise HTTP method + add POST to auth public-route allow-list - tsconfig: add bun-types to compilerOptions.types (fixes bun:test/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
tsc --noEmittype errors in the Bun/Hono monorepo. Final state: 22 pass / 0 fail,npx tsc --noEmitclean (exit 0).Changes
shared/src/utils/pagination.ts— implementedpaginate<T>()(was athrow new Error("not implemented")stub), satisfying the fullPaginatedResponsecontract: page slicing, partial last page, total/totalPages, page/pageSize echo, and empty/out-of-range pages returning empty data.shared/src/types.ts— renamedUser.userName→usernameto reconcile the inconsistency between the shared type, the users route, and the tests.api/src/routes/users.ts— importedbadRequest(previously used but unimported →ReferenceErroronPOST /users); aligned field tousername.api/src/middleware/auth.ts— fixed the public-route allow-list: HTTP method is now normalised (case-insensitive) soPOST /usersis correctly treated as public. Resolved theprocesstype error via tsconfig.tsconfig.json— addedbun-typestocompilerOptions.types(resolvesbun:testmodule +processtype errors). No new dependencies added.Verification
bun test→ 22 pass / 0 failnpx tsc --noEmit→ 0 errorsConstraints honoured
Notes / assumptions
username(lowercase) because that is what the read-only tests and route body expect.paginate()on non-finite / zerosizeinputs. Those paths are not exercised by any test andpaginate()is not yet wired to a route, so they were left out of scope per "fix only what the tests require." Worth a follow-up ifpaginateis later bound to request query params.🤖 Generated with autonomous agent