Conversation
…ages - Implement paginate() utility in shared package (was a stub) - Import badRequest in users route so missing-field POST returns 400 not 500 - Fix case-sensitivity bug in auth middleware public-method allowlist - Rename User.userName field to username for cross-package consistency - Configure tsconfig types/lib so bun-types and process/bun:test 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
Makes
bun testfully green (22 pass / 0 fail) andbunx tsc --noEmitclean. Fixes bugs spanning both theapi(Hono server) andshared(types/utils) packages. No test files were modified and no dependencies were added.Changes
shared— pagination utility: implementedpaginate<T>()(was athrow "not implemented"stub). Returns the fullPaginatedResponse<T>shape (data,page,pageSize,total,totalPages), with out-of-range pages and empty arrays yielding empty data, and a guard against divide-by-zero whensize <= 0.shared— types: renamedUser.userName→usernamefor cross-package consistency (tests and the route handler both useusername). Verified no remaininguserNamereferences repo-wide.api— users route: imported the missingbadRequesthelper from../lib/errors, soPOST /userswith missing fields returns 400 instead of throwing a ReferenceError → 500.api— auth middleware: fixed a case-sensitivity bug in the public-method allowlist. The incoming method is now normalised (c.req.method.toUpperCase()) soPOST /userscorrectly matches as a public route.tsconfig.json: addedtypes: ["bun-types"]andlib: ["ES2022", "DOM"]soprocessand thebun:testmodule resolve (using the already-installedbun-types; no new deps).DOMcovers Hono'sRequest/Response/Headersusage.Verification
bun test→ 22 pass / 0 failbunx tsc --noEmit→ clean (exit 0)Notes / assumptions
packages/api/test/auth.test.tsasserts this. The task was to fix the case-matching bug, not change policy, so this behaviour is preserved. Flagging for awareness: an unauthenticatedPOST /userspermits anonymous account creation, which for a hardened API would conflict with least-privilege principles (ISM-1833/1852). Out of scope here."test-token"whenAPI_TOKENis unset and uses a non-constant-time!==comparison. Acceptable as an e2e fixture; would warrant fail-closed + constant-time comparison if promoted to real use. Left unchanged as out of scope.