Conversation
- Implement paginate() stub in shared with finite-input guards - Fix auth middleware HTTP-method case (POST /users now correctly public) - Add missing badRequest import in users route (fixes 400 path) - Rename shared User.userName -> username to match test/route usage - Add bun-types to tsconfig types to resolve process/bun:test errors
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 (was 9 fail / 13 pass, now 22 pass / 0 fail) and eliminates all
tsc --noEmittype errors across theapiandsharedpackages. No test files, dependencies, or lockfiles were changed.Changes
packages/shared/src/utils/pagination.ts— implemented thepaginate<T>()stub (was throwing "not implemented"). 1-indexed pages,slice-based windowing,totalPagesviaMath.ceil(yields0for empty arrays). AddedNumber.isFiniteguards so non-finitepage/sizefall back to1/10instead of leakingNaNinto the response.packages/api/src/middleware/auth.ts— fixed a case-sensitivity bug in the public-methods list ("post"→"POST"); HTTP methods are uppercase per RFC 7231, soPOST /userswas never matching and fell through to the token check. Also removed a now-stale bug-description comment.packages/api/src/routes/users.ts— added the missingbadRequestimport from../lib/errors(was aCannot find nametype error and a runtimeReferenceErroron the 400 path). Matches the existing pattern inroutes/posts.ts.packages/shared/src/types.ts— renamedUser.userName→usernameto match what the (unmodifiable) test files and route handlers use.userNamehad no other references in code.tsconfig.json— added"types": ["bun-types"]to resolve theCannot find name 'process'/Cannot find module 'bun:test'errors.bun-types(and its transitive@types/node) were already installed and declared as devDependencies — no new dependency added.Verification
Assumptions & notes
username/userNameinconsistency, the tests are authoritative (they can't be modified), so the shared type was moved tousernamerather than editing tests.paginateis exported from@e2e/sharedbut not yet consumed by any route;GET /usersandGET /postsreturn unpaginated arrays, consistent with the tests as written. Wiring pagination into the list endpoints (with query-param validation returning 400 on non-numeric input) would be the natural follow-up if that was the intent.auth.tsfalls back to a hard-coded literal token whenAPI_TOKENis unset — worth a follow-up hardening issue but unrelated to the failing tests.