fix: resolve failing tests and type errors across api and shared packages#50
Open
stooit wants to merge 1 commit into
Open
fix: resolve failing tests and type errors across api and shared packages#50stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
…ages - auth middleware: fix case-sensitivity bug in HTTP method allow-list (compare against uppercase GET/POST as Hono normalises method names) - shared types: align User field name to 'username' across both packages - users route: add missing 'badRequest' import - pagination: implement the paginate stub per the test contract - tsconfig: add bun-types and @e2e/shared path alias for clean tsc
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 type errors in the multi-package TypeScript HTTP API (Hono). After this change: 22/22 tests pass and
tsc --noEmitis clean.Bugs fixed
packages/api/src/middleware/auth.ts) — case-sensitivity bug in the public-route allow-list. Hono normalisesc.req.methodto uppercase, so the lowercase comparison never matched, causing public routes (e.g.POST /users) to wrongly require a token. Now compares against uppercase method names.packages/shared/src/types.ts) — field-name inconsistency between packages. TheUsertype field is now consistentlyusername, matching what the API routes and tests expect.packages/api/src/routes/users.ts) — missingbadRequestimport caused a runtime failure on the 400 (missing fields) path.packages/shared/src/utils/pagination.ts) — implemented thepaginatestub to satisfy the full test contract (page slice, partial last page, out-of-range page, total/totalPages, page/pageSize).bun-types(already installed, no new dependency) sobun:testand theprocessglobal resolve undertsc.Verification
bun test→ 22 pass, 0 failnpx tsc --noEmit→ exit 0, no errorsNotes / assumptions
username), since tests must not be edited.size=0and negativepageinpaginate). These were left untouched to respect the "fix only what the tests require" constraint and avoid scope creep.🤖 Generated with autonomous agent