fix: repair failing tests and type errors across api + shared packages - #135
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api + shared packages#135stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
Renames the shared User.userName field to username to match the API contract the tests assert, implements the paginate utility, uppercases POST in the auth public-method allow-list, imports badRequest in the users route, and references bun-types in tsconfig so process and bun:test resolve. All 22 tests pass and 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 and type errors in the repo. Before: 13 pass / 9 fail, 14
tscerrors. After: 22 pass / 0 fail,tsc --noEmitclean.Five bugs fixed across both packages, matching the seeded areas:
packages/shared/src/types.ts: renamedUser.userName→usernameto match the contract the tests (and API handlers) assert. Structurally propagates throughOmit<User, "id" | "createdAt">, so no stragglers remained.packages/shared/src/utils/pagination.ts: implementedpaginateper the test contract (data,page,pageSize,total,totalPages), including partial-last-page, out-of-range, and empty-array cases. Signature andPaginatedResponse<T>return type unchanged.packages/api/src/middleware/auth.ts: public-method allow-list compared against lowercase"post"; the FetchRequest.methodis uppercase"POST", soPOST /userswas wrongly rejected with 401. Fixed to"POST"(fail-closed allow-list).packages/api/src/routes/users.ts:badRequestwas called but never imported, throwingReferenceError(500 instead of 400). Added to the existing../lib/errorsimport.tsconfig.json: added"types": ["bun-types"]sobun:testand theprocessglobal resolve.bun-typeswas already in root devDependencies — no new dependency added.Verification
bun test-> 22 pass, 0 failbunx tsc --noEmit-> exit 0Constraint compliance
Reviewer notes (out of scope — not fixed here)
Independent review flagged these as follow-ups, deliberately left out under "fix only what the tests require":
paginatedoes not guardpage < 1, fractional pages, or non-positivesize(no production callers today; validate at the eventual caller when it accepts user query params).tsconfignow makesbun-types: "latest"load-bearing for the typecheck — pin to a concrete minor when the dependency freeze lifts.POSTpublic activates unauthenticated writes to/usersand/posts(documented intent, asserted byauth.test.ts), andauth.tsretains a hardcodedtest-tokenfallback — worth a security review before this pattern reaches a real environment.README.md"Known issues" still lists the now-fixed bugs.Assumptions
userName->username, not the reverse).docs/plans/was intentionally left untracked to keep the PR scoped to the fix.