Conversation
- implement paginate() stub in shared package (1-indexed pages, raw totals)
- fix auth middleware case-sensitivity bug ("post" -> "POST") so public POST works
- rename User.userName -> User.username to match tests and api call sites
- add missing badRequest import in users route (was ReferenceError)
- wire already-installed bun-types into tsconfig to resolve bun:test/process
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 9 failing tests and all 14
tsctype errors in the api + shared monorepo. Final state: 22 pass / 0 fail,npx tsc --noEmitclean. Changes are scoped to 5 source files (9 insertions, 22 deletions — most deletions are staleBUG:/TODO:markers). No test files modified, no dependencies added.Fixes
shared/src/utils/pagination.ts— implemented thepaginate()stub. Pages are 1-indexed;page/pageSize/total/totalPagesare returned raw (no clamping) to match the test contract, includingtotalPages: 0for an empty array and emptydatafor out-of-range pages.api/src/middleware/auth.ts— case-sensitivity bug: public-methods list held"post"butc.req.methodis uppercase, so unauthenticated POST wrongly returned 401. Changed to"POST".DELETEstill requires a Bearer token (unchanged, still green).shared/src/types.ts— renamedUser.userName→User.usernameto match the tests and the api call sites (db.ts,users.ts); the type was the inconsistent side.api/src/routes/users.ts— added the missingbadRequestimport from../lib/errors(was throwingReferenceError, failing the 400-on-missing-fields test).tsconfig.json— added"types": ["bun-types"]to resolve thebun:testmodule andprocessglobal type errors.bun-typeswas already in root devDependencies — nothing installed.Verification
Assumptions & notes
userName/usernamefield), the source was corrected, not the test.paginate()does not validate negative/zeropage/size(e.g.page=-1returns a populated slice;size=0yieldsInfinitytotalPages). There is no in-repo caller and the task scoped work to the test contract, so this was left as-is. AMath.max(1, Math.floor(...))clamp would harden it later without breaking thetotalPages: 0empty-array assertion.README.mdstill listsUser.userNameunder "known bugs"; docs-only, left untouched.POST /users/POST /postsaccept unauthenticated writes by design of this fixture; would need auth + a collection notice before production use.