fix: resolve failing tests and type errors across api and shared packages - #129
Open
stooit wants to merge 1 commit into
Open
fix: resolve failing tests and type errors across api and shared packages#129stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
…ages - auth: make public-method allow-list case-insensitive so POST /users is public (was 401) - shared: rename User.userName -> User.username to match consumers and tests - users route: import badRequest so missing-field path returns 400 (was 500 ReferenceError) - shared: implement paginate() to satisfy pagination contract - tsconfig: add bun-types to compilerOptions.types to resolve process/bun:test 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 tests (
bun test) and eliminates all type errors (tsc --noEmit) in the Bun + Hono monorepo. Baseline was 13 pass / 9 fail with 14 tsc errors; now 22 pass / 0 fail and tsc exits 0.Fixes
packages/api/src/middleware/auth.ts) — the public-method allow-list contained"post"(lowercase) whilec.req.methodyieldsPOST, soPOST /usersfell through to the token check and returned 401 instead of being public. Corrected the literal and made the comparison case-insensitive.packages/shared/src/types.ts) —User.userNamerenamed toUser.usernameto match what route handlers and tests expect. This was the source of theOmit<User, ...>tsc errors.packages/api/src/routes/users.ts) —badRequestwas called but not imported, throwing aReferenceErrorsurfaced as 500 instead of the intended 400 on the missing-fields path. Added it to the existing../lib/errorsimport.packages/shared/src/utils/pagination.ts) — implementedpaginate<T>()(previously a throwing stub) to satisfy the full contract: 1-indexed page slicing,total/totalPages(0 for empty arrays),page/pageSizeecho, emptydatafor out-of-range pages.tsconfig.json) — added"types": ["bun-types"]so theprocessglobal andbun:testmodule declarations resolve.bun-typeswas already a devDependency; no new dependency added.Constraints honoured
Verification
bun test→ 22 pass / 0 failbunx tsc --noEmit→ exit 0Assumptions / notes
auth.ts:25warrant a security pass (out of scope here).paginatedefensively clamps non-finite / sub-1sizeto 1; no test or caller exercises those inputs.🤖 Generated with QuantCode