fix: repair failing tests and type errors across api and shared packages - #116
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#116stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- Implement paginate() utility (was an unimplemented stub)
- Fix auth middleware case-sensitivity bug ("post" -> "POST") so POST /users is correctly treated as public
- Rename shared User field userName -> username for consistency with API routes and tests
- Add missing badRequest import in users route handler
- Add bun-types to tsconfig types so tsc resolves bun:test and process
All 22 tests pass; tsc --noEmit is clean.
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 (9 → 0) and all
tsc --noEmittype errors (8 → 0) across theapiandsharedpackages. Final state: 22/22 tests pass,tsc --noEmitclean.Changes
packages/shared/src/utils/pagination.ts— Implementedpaginate(), which was a stub throwingnot implemented. Uses 1-based page indexing,Math.ceilfortotalPages, and returns an empty slice for out-of-range pages, matching the test contract.packages/api/src/middleware/auth.ts— Fixed a case-sensitivity bug in the public-methods allowlist ("post"→"POST"). HTTP methods are uppercase, soPOST /userswas incorrectly requiring a token instead of being public.packages/shared/src/types.ts— Renamed theUserfielduserName→usernameto be consistent with the API route handlers and the test expectations.packages/api/src/routes/users.ts— Added the missingbadRequestimport from../lib/errors, which was causing a runtime failure on the missing-fields validation path (400 response).tsconfig.json— Added"types": ["bun-types"]sotscresolves thebun:testmodule and theprocessglobal (bun-types was already installed; no new dependency).README.md— Updated the known-bugs notes to reflect the fixes.Verification
bun test→ 22 pass / 0 failbunx tsc --noEmit→ exit 0, no errorsAssumptions
username(notuserName) spelling is authoritative, since the test files (which must not be modified) and the API routes both useusername; the shared type was the outlier.process.env.API_TOKENusage in auth middleware is intentional; the reportedprocesstype error was a tsconfig/types gap, resolved by addingbun-types, not by changing the code.