Conversation
- auth: fix HTTP method case-sensitivity in public-methods allow-list ("post" -> "POST") so POST requests are correctly treated as public
- users route: add missing badRequest import causing ReferenceError/TS2552
- shared types: rename User.userName -> username to match the test contract and align both packages
- pagination: implement paginate<T> per its test contract, with clamping/guards for non-finite and out-of-range page/size
- tsconfig: add "bun-types" to types so bun:test and process globals 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 9 failing tests and all 14 type errors in the Bun + Hono monorepo. Baseline was 13 pass / 9 fail with 14
tscerrors; now 22 pass / 0 fail andtsc --noEmitis clean.Changes
packages/api/src/middleware/auth.ts): the public-methods allow-list contained"post"(lowercase). Hono'sc.req.methodis uppercase per RFC 7231, so POST fell through to the token check and returned 401. Changed to"POST". This unblocked both auth middleware > POST /users is public and POST /users > returns 400 for missing fields (the latter was hitting 401 before reaching validation).packages/api/src/routes/users.ts): added the missingbadRequestimport from../lib/errors(already exported and used) — was aReferenceErrorat runtime /TS2552at compile time.packages/shared/src/types.ts): renamedUser.userName→usernameto match the test contract (tests useusernameexclusively as both create input and serialised field). Propagates cleanly throughOmit<User,...>in the db layer.packages/shared/src/utils/pagination.ts): implementedpaginate<T>per the contract inpackages/shared/test/pagination.test.ts(data slice, total, totalPages, page, pageSize, empty-array and out-of-range-page → empty data). Added guards so non-finite (NaN/Infinity) and<1page/size — reachable viaNumber(query)on untrusted input — fall back to safe defaults rather than leakingNaNinto the response.tsconfig.json): added"types": ["bun-types"]sobun:testand theprocessglobal resolve.bun-typeswas already present innode_modules; no dependency was added.Verification
bun test→ 22 pass / 0 failnpx tsc --noEmit→ clean (exit 0)Assumptions & notes
usernamefield name and aligned the shared type + api code to them.POSTroute remaining unauthenticated is the specified contract (asserted byauth.test.ts), so it was left as-is. For a production workload this is worth revisiting (unauthenticated writes).README.mdstill lists these four defects as "known issues"; the non-finite pagination path has no dedicated test (couldn't add one without modifying test files).🤖 Generated with autonomous agent