fix: repair failing tests and type errors across api and shared packages - #136
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#136stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- shared: rename User.userName -> username to match API and tests
- shared: implement paginate() utility per PaginatedResponse contract
- api: import badRequest in users route (fixes 500 -> 400 on invalid body)
- api: fix auth middleware method allow-list case ("post" -> "POST")
- tsconfig: add bun-types so bun:test and process type-check (no new deps)
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 9 failing tests and all
tsc --noEmiterrors in the multi-package API repo. End state: 22 pass / 0 fail,tscexit 0. No test files were modified and no dependencies were added.Root causes & fixes
User.userNamerenamed tousername. The field name was inconsistent: every consumer (API routes, DB layer, and all tests) usedusername; only the shared type was wrong.paginate()stub (previously threwnot implemented). Returns the exactPaginatedResponse<T>shape (data, page, pageSize, total, totalPages); rawpageis echoed back as the tests require (no clamping).badRequestimport. Its absence caused aReferenceErroron the invalid-body path, returning 500 instead of 400.["GET", "post"]→["GET", "POST"], soPOST /usersis correctly treated as public."types": ["bun-types"]sobun:testand theprocessglobal type-check.bun-typeswas already an existing devDependency (transitively pulls in@types/node); no new dependencies were added.Verification
bun test→ 22 pass / 0 failbunx tsc --noEmit→ exit 0package.jsonunchanged, and theuserName→usernamerename has no stragglers.Assumptions / notes
README.mdretains the lineUser.userName should be usernameunder "Known issues (intentional — for agent testing)" — this is test-fixture scaffolding, not stale user docs, so it was intentionally left as-is.POST /usersis public by design per the middleware policy and is asserted byauth.test.ts; preserved as specified. Flagged here only as a note: in a real service, unauthenticated writes would warrant an access-control review.paginate()has no guards forpage < 1/size <= 0. There is no production caller today and the tests don't exercise these, so input validation was left out to honour the "fix only what tests require" constraint — worth adding at the route boundary if it's ever wired to query-string input.