fix: repair failing tests and type errors across api and shared packages#73
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#73stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- auth middleware: correct public-method allow-list to uppercase 'POST' so POST /users is not incorrectly rejected with 401 (Hono normalises methods) - shared types: reconcile User.userName -> username to match db layer, route handlers, and test expectations across both packages - routes/users: add missing badRequest import - shared utils: implement pagination utility (1-indexed page, partial last page, empty input, out-of-range page all handled) - tsconfig: add bun-types and @e2e/shared path alias to resolve bun:test, process global, and cross-package imports
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 (now 22/22 passing) and all
tsc --noEmittype errors across theapiandsharedpackages. Bugs spanned both packages as anticipated.Fixes
packages/api/src/middleware/auth.ts): the public-method allow-list contained lowercase"post", but Hono normalises HTTP methods to uppercase per RFC 7231, soPOST /usersnever matched and was rejected with401. Corrected to"POST".packages/shared/src/types.ts):User.userNamewas inconsistent with the db layer, route handlers, and test expectations, all of which useusername. Reconciled the type tousernameso the field name is consistent across both packages.packages/api/src/routes/users.ts): added the missingbadRequestimport that caused a runtime/type failure.packages/shared/src/utils/pagination.ts): implemented the previously-stubbed function — 1-indexed pages, correct partial last page, empty input (totalPages: 0, noNaN), and out-of-range pages (returns empty data without crashing).tsconfig.json): addedbun-typesand the@e2e/sharedpath alias to resolvebun:test, theprocessglobal, and cross-package imports. No new dependencies added.Verification
bun test-> 22 pass, 0 failtsc --noEmit-> clean (exit 0)Constraints honoured
Assumptions
usernameoveruserName).bun-types/@e2e/sharedtsconfig entries rely on packages already present innode_modules; no additions topackage.jsonor the lockfile were made.