fix: resolve failing tests and type errors across api and shared packages - #123
Open
stooit wants to merge 1 commit into
Open
fix: resolve failing tests and type errors across api and shared packages#123stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
…ages
- implement paginate() page-slice contract in shared, normalising page/size
to prevent negative-size over-fetch and NaN/non-integer input
- rename User.userName -> username to match API usage and test expectations
- import missing badRequest in users route (fixed 500 on invalid POST body)
- correct POST method casing in auth public allow-list ("post" -> "POST")
- reference bun-types in root tsconfig for bun:test and 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 9 failing tests and eliminates all TypeScript type errors in the monorepo. After this change
bun testreports 22 pass / 0 fail andnpx tsc --noEmitexits clean.Root causes & fixes
paginate()was an unimplemented stub throwingnot implemented(7 test failures). Implemented the full page-slice contract:total,totalPages(Math.ceil), correct slice offset, out-of-range pages return empty data, empty array yieldstotal: 0, totalPages: 0. Inputs are normalised once at the top (safeSize/safePage) so a negative/Infinity/NaN/non-integersizeorpagecan no longer trigger an over-fetch (e.g.size = -5previously returned most of the array viaslice(0, -5)).Usertype mismatch — source declareduserNamewhile the tests and API handlers useusername. RenamedUser.userName -> username. Becausedb.createderives its param fromOmit<User, "id" | "createdAt">, the single rename propagated structurally with no straggler call-sites.badRequestwas referenced but not imported from../lib/errors, causing a runtimeReferenceError(Hono returned 500 instead of 400). Added it to the existing import. Fixes "POST /users returns 400 for missing fields".["GET", "post"];c.req.methodis always uppercase, so"post"never matched and POST was incorrectly challenged for a Bearer token. Changed to["GET", "POST"]. Fixes "POST /users is public". No other methods (PUT/DELETE/PATCH) were broadened."types": ["bun-types"]sobun:testand theprocessglobal resolve.bun-typeswas already a root devDependency; this only activates it. No new dependencies installed.Constraints honoured
Assumptions & notes
Userfield was renamed tousername(matching tests).POST /usersandPOST /postsare public perauth.test.ts("POST is intentionally public"). Flagging that unauthenticated record creation without rate limiting is worth a deliberate product decision if this reflects a real API rather than an e2e fixture.HEAD/OPTIONSstill require auth (pre-existing, out of scope) — a possible follow-up for CORS preflight.Verification