fix: repair failing tests and type errors across api and shared packages - #148
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#148stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- Add bun-types to tsconfig types to resolve bun:test/process type errors - Align User type field to username to match test contracts - Import missing badRequest in users route (500 -> 400) - Fix auth middleware case-sensitivity so POST is public - Implement paginate() utility per 1-indexed contract
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 14
tsc --noEmiterrors in the multi-package repo. Final state: 22 pass / 0 fail, zero type errors. No test files modified, no dependencies added.Changes (5 source/config files)
tsconfig.json"types": ["bun-types"]— resolvesbun:test(TS2307) andprocess(TS2580) errors.bun-typeswas already a root devDependency; no new deps.packages/shared/src/types.tsUserfielduserName→usernameto match what the (unmodifiable) test files send and assert.packages/api/src/routes/users.tsbadRequestimport from../lib/errors— theReferenceErrorwas surfacing as a 500 where a 400 was expected.packages/api/src/middleware/auth.ts"post"; Hono passes methods uppercase, soPOST /usersreturned 401 instead of being public. Allow-list not broadened — DELETE/PUT/PATCH still require a token.packages/shared/src/utils/pagination.tspaginate()stub per the 1-indexed contract (no page clamping, no empty-array special-casing).Verification
bun test→ 22 pass / 0 failbunx tsc --noEmit→ exit 0, no outputAssumptions
username, notuserName): forced by the test files, which are off-limits to edit — they calldb.users.create({ username: ... })and assertbody.username.bun-typesfor tsconfig: used the already-installed root devDependency rather than adding@types/node, honouring the no-new-deps constraint.Note (out of scope — flagged, not changed)
The auth middleware treats POST as public, so
POST /userscreates records (email/username = personal information) with no token, and there's a hardcoded"test-token"fallback whenAPI_TOKENis unset. Current tests pin this behaviour in place, so changing it would require test edits that were off-limits. Worth follow-up if this reaches a real deployment (relevant: ISM-1546, ES8 MFA, APP 11).