fix: repair failing tests and type errors across api and shared - #137
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared#137stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- shared: implement paginate util (was a stub) with non-finite input guards - shared: rename User.userName -> username to match usages and tests - api/routes/users: import missing badRequest helper (was 500 instead of 400) - api/middleware/auth: normalise HTTP method case so POST is treated as public - tsconfig: add bun-types to resolve bun:test and process/node globals
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 repo. Baseline was 9 failing tests + 14 type errors; now 22/22 tests pass and
bunx tsc --noEmitis clean (exit 0).Bugs spanned both
packages/apiandpackages/shared, matching the areas called out in the task.Changes
packages/shared/src/utils/pagination.tspaginatestub (wasthrow "not implemented"). Returns{ data, page, pageSize, total, totalPages }; out-of-range pages yield an empty slice, empty array yieldstotalPages: 0. AddedNumber.isFiniteguards so non-finite inputs (e.g.Number(query("page"))→NaN) fall back to1rather than serialising tonull.packages/shared/src/types.tsUser.userName→usernameto match the field name used everywhere in the API routes and tests.packages/api/src/routes/users.tsbadRequestimport from../lib/errors. Previously threw aReferenceError→ 500 instead of the intended 400 for missing fields.packages/api/src/middleware/auth.ts"post", so"POST"never matched and public writes were rejected with 401. Normalised the incoming method with.toUpperCase()against a canonical uppercase list. Fails closed — unrecognised methods still require a token.tsconfig.json"types": ["bun-types"]to resolveCannot find module 'bun:test'andCannot find name 'process'.bun-typeswas already a devDependency;@types/nodeglobals come in transitively. No new dependency.Verification
```
bun test → 22 pass, 0 fail
bunx tsc --noEmit → exit 0, zero errors
```
Constraints honoured
Assumptions
Follow-ups (out of scope, not addressed)
Surfaced during review — no live caller today, so non-blocking: