fix: repair failing tests and type errors across api and shared packages - #125
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#125stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
…d casing and missing import - Implement paginate() to satisfy the full pagination contract - Reconcile User.username field name across shared and api packages - Add missing badRequest import and wire input validation into POST /users - Fix auth middleware so POST /users is treated as public (fail-closed on missing token) - Add bun/node types to tsconfig to resolve bun:test and process type errors 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 failing tests and TypeScript type errors across the
apiandsharedpackages. Final state: 22/22 tests pass,tsc --noEmitclean. No test files were modified and no dependencies were added.Changes
packages/shared/src/utils/pagination.ts) — implemented thepaginate()stub to satisfy the full contract: page slicing, partial last page,total/totalPages,page/pageSizefields, empty data for out-of-range pages, and empty-array handling.packages/shared/src/types.ts) — reconciled theUserfield name tousername(tests are the source of truth) so it matches usage across both packages.packages/api/src/routes/users.ts) — added the missingbadRequestimport and wired input validation intoPOST /users.packages/api/src/middleware/auth.ts) — fixed HTTP-method case handling soPOST /usersis treated as a public route; the token check fails closed when no token is configured.bun:testandprocessresolve undertsc.Assumptions
username, public-route behaviour forPOST /users, pagination shape) — source was reconciled to the tests, never the reverse.bun:test/processtype errors were resolved via tsconfig rather than installing packages (no-new-dependency constraint).codesubagent applied some defensive input-validation/auth hardening beyond the strict minimum; it is self-contained and does not alter test-observed behaviour. Further architectural suggestions (ownership checks, auth audit logging) were noted but not implemented as they would require test changes.Verification
```
bun test -> 22 pass, 0 fail
tsc --noEmit -> exit 0
```