fix: repair failing tests and type errors across api and shared packages#64
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#64stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- implement paginate() stub in shared (slice, total, totalPages) - fix auth middleware case-sensitivity for public POST method - reconcile User.username field name between packages - add missing badRequest import in users route - add bun-types to tsconfig types for clean tsc --noEmit
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 multi-package TypeScript HTTP API. After the change,
bun testreports 22 pass / 0 fail andtsc --noEmitexits clean with zero errors.Changes
packages/shared/src/utils/pagination.ts— implemented thepaginate<T>()stub: 1-indexed page slicing,totalfromitems.length,totalPagesviaMath.ceil(total / pageSize), correctpage/pageSizefields. Handles partial last pages, out-of-range pages, and empty arrays.packages/api/src/middleware/auth.ts— fixed a case-sensitivity bug: public-method matching used lowercase while Hono normalisesc.req.methodto uppercase, so the intentionally publicPOST /userswas treated as protected. Protected methods (e.g.DELETE) remain protected.packages/shared/src/types.ts+packages/api/src/routes/users.ts— reconciled the inconsistent User field name tousername, matching the route handler and test assertions.packages/api/src/routes/users.ts— added the missingbadRequestimport.tsconfig.json— addedbun-typestocompilerOptions.typessotscrecognises Bun globals, eliminating spurious type errors without adding any dependency.Verification
bun test→ 22 pass, 0 failnpx tsc --noEmit→ exit 0, no errorsAssumptions / constraints honoured
bun-typeswas already present; only referenced via tsconfig).username(lowercase) chosen because the test suite asserts that field.POSTconfirmed intentional by the test suite.🤖 Generated with QuantCode autonomous agent