Conversation
…ages - import missing badRequest helper in users route (was 500, now 400) - fix case-sensitivity bug in auth middleware public-method check - rename User.userName to username to match callers and tests - implement paginate() utility to satisfy full contract - register bun-types in tsconfig so bun:test/process resolve
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 multi-package API repo. All 22 tests pass and
tsc --noEmitis clean (exit 0). No test files modified, no dependencies added.Changes
packages/api/src/routes/users.ts— imported the missingbadRequesthelper (already defined inlib/errors.tsalongsidenotFound). POST /users with missing fields now returns 400 instead of throwing a ReferenceError → 500.packages/api/src/middleware/auth.ts— fixed a case-sensitivity bug: the public-method allow-list contained"post"(lowercase) whilec.req.methodis always uppercase, so POST /users never matched and got a 401. Normalised the comparison to be case-insensitive on both sides.packages/shared/src/types.ts— renamedUser.userName→usernameto match the field name used by the route handlers and the (unmodifiable) tests. Fixed theTS2561errors.PaginatedResponsealready matched the pagination test contract, so it was left unchanged.packages/shared/src/utils/pagination.ts— implemented thepaginate()stub: 1-indexed slicing,total/totalPagesviaMath.ceil, empty data for out-of-range pages, empty-array handling. Added cheap guards for zero/negativesizeand sub-1page.tsconfig.json— added"types": ["bun-types"]sobun:testandprocessresolve.bun-typeswas already an installed devDependency; TypeScript just wasn't auto-including it. No install required.Verification
Assumptions / notes
auth.test.tsasserts POST /users is deliberately public; that policy was preserved as required. Flagging: for a real government workload, unauthenticated writes to a user store is an ISM-1546 concern (anonymous record creation, no audit attribution) — production would want auth or at minimum rate limiting plus source-identity audit logging.