fix: make all tests pass and eliminate type errors - #134
Open
stooit wants to merge 1 commit into
Open
Conversation
Renames User.userName to username to match API and test usage, adds the missing badRequest import in the users route, fixes the lowercase 'post' method check that made POST /users incorrectly require a token, implements the paginate() utility, and adds bun-types to tsconfig so bun:test and process 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 9 failing tests and all 15
tsc --noEmittype errors across theapiandsharedpackages. Now: 22/22 tests pass,tsc --noEmitexits clean.Fixes
packages/shared/src/utils/pagination.tspaginate()(slice +Math.ceiltotal pages)packages/api/src/routes/users.tsbadRequestto the errors import (was aReferenceError→ 500 instead of 400)POST /users returns 400 for missing fieldspackages/api/src/middleware/auth.ts"post"in the public-methods list →"POST"(HTTP methods are uppercase per RFC 7231)POST /users is public (no token required)packages/shared/src/types.tsUser.userName→usernameto match the API route and test usageTS2561type errorstsconfig.json"types": ["bun-types"](already an installed devDependency) sobun:testandprocessresolvebun:test/processtype errorsVerification
bun test→22 pass, 0 failbunx tsc --noEmit→ exit 0, no outputConstraints honoured
userName→usernamedirection was chosen to match the tests.bun-typeswas already present.Notes for reviewers (non-blocking, out of scope)
paginate()has no guards for negative/zeropage/size; no caller or test exercises those branches, so it was kept test-driven. Worth clamping if it's ever wired to untrusted query input.auth.tsfalls back to a hardcoded"test-token"whenAPI_TOKENis unset (CWE-798). Fine for this test corpus; would need a fail-closed guard before production.README.mdstill lists these as "intentional bugs" — left as-is.🤖 Generated autonomously.