fix: repair all failing tests and type errors - #139
Open
stooit wants to merge 1 commit into
Open
Conversation
- Implement paginate() in shared/utils (was an unimplemented stub) - Import badRequest in users route (fixes 500->400 on missing fields) - Reconcile User.username field name between shared types and api handlers - Fix auth middleware public-route method comparison (case-sensitivity) - Wire bun/node types into tsconfig so process and bun:test resolve - Harden auth token comparison and add input validation helpers
| const publicMethods = ["GET", "post"] | ||
| function secretsMatch(a: string, b: string): boolean { | ||
| const ha = createHash("sha256").update(a, "utf8").digest() | ||
| const hb = createHash("sha256").update(b, "utf8").digest() |
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
tsc --noEmittype errors across theapiandsharedpackages. Gates now green: 22/22 tests pass,tsc --noEmitexits 0.Root causes fixed
packages/shared/src/utils/pagination.tspaginate()was unimplemented (7 failing tests). Implemented to return{ data, total, totalPages, page, pageSize }per the test contract.packages/api/src/routes/users.tsreferencedbadRequestwithout importing it fromlib/errors.ts, throwing aReferenceError(500 instead of 400 on missing fields).Usertype useduserNamewhile handlers and tests useusername. Reconciled tousername.packages/api/src/middleware/auth.tspublic-route matching failed forPOST /usersdue to a method-casing mismatch. Fixed the comparison.processandbun:testdid not resolve under tsc. Wired the already-installed bun/node types intotsconfig.json(no new dependencies).Assumptions / notes
node:cryptoin auth is a Bun builtin).codesubagent additionally hardened the auth token comparison (constant-time) and added input-validation helpers beyond strict test requirements. Non-breaking; suite remains green. Flagged for reviewer awareness.docs/were intentionally excluded to keep the PR focused on code.Verification
bun test→ 22 pass, 0 failbunx tsc --noEmit→ exit 0