fix: make all tests pass and eliminate type errors#51
Open
stooit wants to merge 1 commit into
Open
Conversation
…d name, repair imports - Implement paginate() in shared (1-indexed, totalPages, out-of-range -> empty) - Fix auth middleware public-method check to be case-insensitive (POST /users now public) - Rename User.userName -> username for cross-package consistency - Import badRequest from ../lib/errors in users route - Set tsconfig types to bun-types so process/bun:test resolve without new deps
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
api(Hono) andsharedpackages. Final state:bun test→ 22 pass / 0 fail,npx tsc --noEmit→ clean (exit 0).Bugs fixed
packages/shared/src/utils/pagination.ts) — replaced thethrow new Error("not implemented")stub with a realpaginate<T>(): 1-indexedpage,totalPages = ceil(total/size)(0 when empty), out-of-range pages return emptydata, correct partial-last-page slicing.packages/api/src/middleware/auth.ts) — the public-method check compared a lowercase literal against Hono's uppercasec.req.method, soPOST /userswas wrongly treated as protected. Normalised the comparison to be case-insensitive.packages/shared/src/types.ts) —User.userNamerenamed tousernameto match the tests and usage across both packages.packages/api/src/routes/users.ts) —badRequestis now imported from the existing../lib/errorshelper (no new dependency).process/bun:test(tsconfig.json) — setcompilerOptions.typesto["bun-types"]so the already-present ambient Bun/Node types resolve. No dependencies added.Constraints honoured
package.jsonuntouched).Assumptions
datafor out-of-range pages (from the pagination test contract).username(lowercase) is canonical, since test files (uneditable) use it.page<=0/size=0are not guarded — not exercised by tests, not wired to a live route.Verification