fix: repair failing tests and type errors across api and shared packages - #133
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#133stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- auth middleware: fix HTTP method case-sensitivity so public GET/POST routes match correctly - shared types: align User field to 'username' (was 'userName') to match consumers and tests - users route: restore missing badRequest import so invalid payloads return 400 not 500 - pagination: implement paginate() to satisfy shared package test contract - tsconfig: wire up existing bun-types so 'process' and 'bun:test' resolve
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 errors in the multi-package repo.
bun testnow reports 22 pass / 0 fail andbunx tsc --noEmitexits clean. No test files were modified and no dependencies were added.Fixes
packages/api/src/middleware/auth.ts): fixed an HTTP-method case-sensitivity bug in the public allow-list (["GET", "post"]→["GET", "POST"]with.toUpperCase()normalisation) so unauthenticated public GET/POST routes are matched correctly. DELETE/PUT/PATCH still correctly require a token.packages/shared/src/types.ts): aligned theUserfield tousername(wasuserName) so the shared type, both API route handlers, and the tests agree. Renaming the type — rather than the routes — was the correct direction, since the tests (which must not change) useusername.packages/api/src/routes/users.ts): restored the missingbadRequestimport fromlib/errors.ts(already exported and already imported in the siblingposts.ts), so invalid payloads return 400 instead of a 500 ReferenceError.packages/shared/src/utils/pagination.ts): implemented the previously-stubbedpaginate()to satisfy the shared test contract — correct page slicing,page/pageSize/total/totalPages, out-of-range → empty data, and empty-input handling. Verified no off-by-one.tsconfig.json): added"types": ["bun-types"](already present in devDependencies + node_modules) soprocessandbun:testresolve. Wires up an existing dependency; the alternative (@types/node) would have been a new dependency, which was disallowed.Verification
bun test-> 22 pass / 0 failbunx tsc --noEmit-> clean (exit 0)Assumptions
usernamebecause the (unmodifiable) tests assert onusername.bun-typeswas preferred over@types/nodeto honour the no-new-dependencies constraint.Generated with autonomous agent