Skip to content

fix: resolve failing tests and type errors - #297

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-914-1794479473
Open

stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-914-1794479473

Conversation

@stooit

@stooit stooit commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • auth middleware: publicMethods had "post" in lowercase, so it never matched the method on incoming requests. It is now "POST". The doc comment now says which methods bypass auth.
  • shared types: renamed User.userName to username so it matches the routes and tests.
  • users route: added the missing badRequest import.
  • paginate: implemented, so it returns the page slice plus page, pageSize, total and totalPages. It throws a RangeError if page or size is not a positive integer.
  • tsconfig: added "types": ["bun-types"], which was already installed. This fixes the bun:test and process type errors.
  • Removed stale // BUG: comments.

All tests pass (22 of 22) and tsc --noEmit reports no errors. The change was reviewed, and re-reviewed after the follow-up commits.

⚠️ Needs a policy decision: POST no longer needs auth

Before this change, POST requests needed a token only because the lowercase entry never matched. This fix follows auth.test.ts and the documented policy, which say POST is public. As a result, POST /users and /posts now work without a token. Anyone can create users, or create posts with any authorId. Test files couldn't be changed for this task, so the behaviour follows the test. Please confirm unauthenticated writes are intended. If not, remove POST from publicMethods and update the test to expect 401.

Assumptions and follow-ups

  • paginate rejecting invalid input (page or size that is not a positive integer) goes beyond what the tests ask for. It's there to stop wrong results such as a negative slice or Infinity pages. No route calls it yet.
  • Existing issues left as they were: API_TOKEN falls back to "test-token" when unset, the token comparison isn't constant-time, OPTIONS and HEAD requests need auth, and bun-types is set to latest rather than a pinned version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant