fix: repair failing tests and type errors across api and shared packages - #131
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#131stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- users route: import missing badRequest helper (was 500, now 400) - shared User type: rename userName -> username for cross-package consistency - auth middleware: correct public-methods allow-list literal POST (was 'post') - shared pagination: implement paginate() stub - tsconfig: wire up existing bun-types devDependency for ambient types
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 Bun + Hono TypeScript monorepo.
bun test→ 22 pass / 0 fail;tsc --noEmit→ clean (exit 0).No test files,
package.json, or lockfiles were modified. No dependencies added.Root-cause fixes
packages/api/src/routes/users.tsbadRequestused but not imported →ReferenceErrorturned the missing-fields case into a 500 instead of 400badRequestto the existing import from../lib/errorspackages/shared/src/types.tsUser.userNameinconsistent with the{ username }shape the DB layer and tests use (TS2561)username— fixes it at the source of truth rather than casting at call sitespackages/api/src/middleware/auth.ts"post"; HTTP verbs are case-sensitive so POST wrongly required a token (401 instead of 201)"POST". Comparison is against literal verbs (fail-closed)packages/shared/src/utils/pagination.tspaginate()was an unimplemented stub (7 failing tests)0for empty array), page/pageSize echo,[]for out-of-range pagestsconfig.jsonbun-types(already a devDependency) was never wired into compiler options → TS2580process, TS2307bun:test"types": ["bun-types"]— uses an existing devDependency, adds nothing newReview notes / assumptions
reviewsubagent: no blockers. A first pass had added a.toUpperCase()normalisation to the auth method check; that was scope creep in a security-relevant path and biased fail-open, so it was removed — the allow-list now matches literal verbs and all 22 tests still pass.paginate()does not guard againstNaN/Infinityinputs. It has no call site today, so no untrusted-input path exists — aNumber.isFiniteguard is recommended before wiring it to query params.POST /usersis intentionally public perauth.test.ts— an unauthenticated write path would not meet ISM-1546 in a production service. Preserved as the tests define it.process.env.API_TOKEN ?? "test-token"is a hardcoded default credential (ISM-1685); safe here because tests setAPI_TOKEN, but should fail-closed in production.Verification