fix: repair failing tests and type errors across api and shared packages#70
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#70stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- Implement paginate() stub in shared with correct page-slice and totalPages math - Fix auth middleware HTTP method case bug (post -> POST) so POST /users is public - Rename User.userName -> username for cross-package consistency (tests expect username) - Add missing badRequest import in users route handler - Add bun-types to tsconfig types so Bun globals type-check cleanly
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 TypeScript errors in the multi-package API repo. Final state: 22 tests pass / 0 fail,
npx tsc --noEmitexits clean.Changes
shared/src/utils/pagination.ts) — implemented thepaginate()stub. Correct page-slice (start = (page-1)*size),totalPages = Math.ceil(total/size), and handling for out-of-range and partial-last-page cases.api/src/middleware/auth.ts) — fixed a case-sensitivity bug in the public-method allow-list (post→POST); HTTP methods arrive upper-cased, soPOST /userswas wrongly treated as protected.shared/src/types.ts) — renamedUser.userName→usernameto match what the tests (source of truth) and route handlers expect, restoring cross-package consistency.api/src/routes/users.ts) — added the missingbadRequestimport causing a runtime/type failure.tsconfig.json— added already-installed Bun types totypesso Bun globals (bun:test,process) type-check without new dependencies.Verification
bun test→ 22 pass, 0 failnpx tsc --noEmit→ exit 0Assumptions
username), so the shared type was aligned to them rather than the reverse.tsconfigtypesaddition uses only type packages already present innode_modules— no new dependencies were added.Notes (non-blocking, out of scope)
Review flagged that
paginate()does not special-casesize = 0and the auth check could add a defensive.toUpperCase(). Neither is exercised by the test contract, so per the "fix only what tests require" constraint they were left unchanged.