fix: repair failing tests and type errors across api and shared packages - #102
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#102stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- Implement paginate() stub in shared with correct edge-case handling - Fix auth middleware case-sensitivity (lowercase 'post' in public methods) - Add missing badRequest import and correct username field in users route - Align username field name between shared types and api consumers - Add bun-types to tsconfig types to resolve bun:test/process type errors
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
bun testcases and eliminates alltsc --noEmittype errors across theapiandsharedpackages. No test files were modified and no dependencies were added.Final state: 22 pass / 0 fail,
tsc --noEmit0 errors.Changes
shared/src/utils/pagination.ts— Implemented thepaginate()stub. Handles 1-indexed pages, partial last page, out-of-range pages (returns emptydata), empty arrays, and asize=0guard againstInfinityintotalPages.api/src/middleware/auth.ts— Fixed a case-sensitivity bug: the public-methods allow-list contained lowercase"post", but Hono delivers uppercased HTTP methods, soPOSTwas silently requiring auth. Corrected to"POST".PUT/DELETE/PATCHremain protected.api/src/routes/users.ts— Added the missingbadRequestimport and corrected theusernamefield name to match the sharedUsertype.shared/src/types.ts— Aligned theUserfield name (userName→username) so shared types and all API consumers/tests agree.tsconfig.json— Added"types": ["bun-types"](already a devDependency) to resolvebun:test/processtype errors undertscwithout touching test files.Assumptions
username(lowercase) spelling is canonical, since the tests and all API route consumers use it; the shared type was the outlier.GET+POST(per the middleware's own documented list).bun-typeswas already present, so referencing it in tsconfig adds no new dependency.Verification
bun test→ 22 pass, 0 failnpx tsc --noEmit→ exit 0, no errors