fix: repair failing tests and type errors across api and shared packages - #124
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#124stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
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 eliminates all TypeScript errors across the
apiandsharedpackages. Baseline was 13 pass / 9 fail with 16 tsc errors; now 22/22 tests pass andtsc --noEmitis clean. No test files were modified and no dependencies were added.Fixes
packages/shared/src/types.ts) — theUsertype useduserNamewhile every test assertsusername(11 references). Reconciled the type tousernameto match the test contract.packages/api/src/routes/users.ts) — added the missingbadRequestimport from../lib/errors. This was throwing aReferenceErrorinstead of returning 400 for missing fields.packages/api/src/middleware/auth.ts) — the public-methods allow-list held"post"(lowercase) butc.req.methodis always uppercase per RFC 9110, so public POST was forced through token auth. Hoisted to aPUBLIC_METHODSconst and normalised with.toUpperCase().packages/shared/src/utils/pagination.ts) — implemented the stub: floors page/size at 1, computestotalPagesviaMath.ceil, slices the page (out-of-range yields[]), returnstotal: 0, totalPages: 0for empty input.tsconfig.json) — added"types": ["bun-types"](already a root devDependency) to resolvebun:test/processerrors in source and tests.Assumptions
username, notuserName. The task hint suggested tests useduserName, but they actually assertusername. The tests are the contract, so the source type was fixed to match.Verification
bun test && bunx tsc --noEmit→ 22 pass / 0 fail, tsc exit 0.Follow-ups (not required by tests, left untouched)
"test-token"whenAPI_TOKENis unset — a weak default credential that should fail closed in any deployed context (ISM-1685/ISM-0421).