Conversation
…thod case - Implement paginate() stub in shared/utils (page slicing, totals, edge cases) - Rename User.userName -> username in shared types to match API/tests usage - Fix auth middleware method-case bug (publicMethods had 'post'; now compares uppercased) - Add missing badRequest import in users route handler - Add 'bun-types' to tsconfig types array 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 type errors in the monorepo. Result:
bun test→ 22 pass / 0 fail (was 13/9) andnpx tsc --noEmit→ 0 errors (was 14).Changes
packages/shared/src/utils/pagination.ts— implemented thepaginatestub: slices at(page-1)*size, returnsdata,page,pageSize,total,totalPages. Handles empty arrays and out-of-range pages (emptydata); clampspage/sizeto a floored minimum of 1 to avoid divide-by-zero. Fixes 7 pagination tests.packages/shared/src/types.ts— renamedUser.userName→username. The type declaration was the odd one out; all three test files, both route handlers, and the POST body contract useusername. Clears the TS2561 field-mismatch errors (incl. ones inside test files that can't be edited).packages/api/src/middleware/auth.ts— fixed a case-sensitivity bug:publicMethodscontained"post"soPOSTnever matched and was forced down the token path (401). Now["GET","POST"]compared via.toUpperCase(). Fixes the "POST /users is public" test; the DELETE→401 test still passes, so the auth boundary is unchanged.packages/api/src/routes/users.ts— added the missingbadRequestimport from../lib/errors(was a runtime ReferenceError / TS2552). Fixes the "400 for missing fields" test.tsconfig.json— added"types": ["bun-types"]. Config-only fix;bun-typeswas already present innode_modules/devDependencies but not being loaded. Resolves thebun:test(TS2307) andprocessglobal (TS2580) errors. No new dependencies added.Assumptions
username, tests were left untouched.bun:test/processerrors were treated as a tsconfigtypesconfiguration gap rather than a missing dependency (verifiedbun-typesalready installed).Notes for reviewer (pre-existing, out of scope — left unchanged)
POST /usersbeing unauthenticated is asserted byauth.test.ts; for a government API this permits unauthenticated writes (tension with ISM-1546 / audit attributability) — flagged for a product decision, not silently changed.middleware/validate.tsrequireFieldsis defined but unused; both routes hand-roll validation.Verification
bun test→ 22 pass / 0 failnpx tsc --noEmit→ exit 0, no errors