fix: repair failing tests and type errors across api and shared packages#74
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#74stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- implement paginate() utility per the PaginatedResponse contract - rename User.userName field to username for cross-package consistency - fix auth middleware HTTP-method casing so POST /users is public - import badRequest in users route (400 instead of 500 on bad input) - add bun-types to tsconfig types to resolve bun:test/process 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 TypeScript errors so that
bun test && bunx tsc --noEmitpasses cleanly (22 pass, 0 fail; 0 type errors). Bugs spanned both theapiandsharedpackages. No test files were modified and no dependencies were added.Fixes
packages/shared/src/utils/pagination.ts): implemented thepaginate()stub per thePaginatedResponsecontract —dataslice,page,pageSize,total,totalPages, with correct handling of empty arrays and out-of-range pages.packages/shared/src/types.ts): renamed theUser.userNamefield tousernameto resolve the cross-package inconsistency (api routes and tests expectusername).packages/api/src/middleware/auth.ts): fixed a case-sensitivity bug — the public-route allow-list used lowercase"post", which never matched Hono's uppercasec.req.method, soPOST /userswas incorrectly requiring a token.packages/api/src/routes/users.ts): added the missingbadRequestimport from../lib/errors; the missing symbol was throwing aReferenceError(HTTP 500) instead of returning the intended 400 for missing fields.tsconfig.json): added"types": ["bun-types"]to resolvebun:testandprocessglobal type-resolution errors (bun-typeswas already installed;@types/nodewas intentionally not added).TODO/BUGcomments describing the bugs that were fixed.Verification
bun test-> 22 pass, 0 fail (37 assertions, 4 files)bunx tsc --noEmit-> 0 errorsAssumptions
Userfield name isusername(lowercase), since the unmodifiable test files and api route handlers use it; thesharedtype was the outlier.size = 0pagination edge case is left unguarded as no test or caller exercises it and adding behavior beyond the test contract would be scope creep.