Skip to content

fix: repair failing tests and type errors across api and shared packages - #125

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2810-1786291922
Open

fix: repair failing tests and type errors across api and shared packages#125
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2810-1786291922

Conversation

@stooit

@stooit stooit commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and TypeScript type errors across the api and shared packages. Final state: 22/22 tests pass, tsc --noEmit clean. No test files were modified and no dependencies were added.

Changes

  • Pagination (packages/shared/src/utils/pagination.ts) — implemented the paginate() stub to satisfy the full contract: page slicing, partial last page, total/totalPages, page/pageSize fields, empty data for out-of-range pages, and empty-array handling.
  • Shared types (packages/shared/src/types.ts) — reconciled the User field name to username (tests are the source of truth) so it matches usage across both packages.
  • Route handler (packages/api/src/routes/users.ts) — added the missing badRequest import and wired input validation into POST /users.
  • Auth middleware (packages/api/src/middleware/auth.ts) — fixed HTTP-method case handling so POST /users is treated as a public route; the token check fails closed when no token is configured.
  • tsconfig.json — added bun/node types so bun:test and process resolve under tsc.

Assumptions

  • Tests define the contract (field names like username, public-route behaviour for POST /users, pagination shape) — source was reconciled to the tests, never the reverse.
  • bun:test/process type errors were resolved via tsconfig rather than installing packages (no-new-dependency constraint).
  • The code subagent applied some defensive input-validation/auth hardening beyond the strict minimum; it is self-contained and does not alter test-observed behaviour. Further architectural suggestions (ownership checks, auth audit logging) were noted but not implemented as they would require test changes.

Verification

```
bun test -> 22 pass, 0 fail
tsc --noEmit -> exit 0
```

…d casing and missing import

- Implement paginate() to satisfy the full pagination contract
- Reconcile User.username field name across shared and api packages
- Add missing badRequest import and wire input validation into POST /users
- Fix auth middleware so POST /users is treated as public (fail-closed on missing token)
- Add bun/node types to tsconfig to resolve bun:test and process type errors

All 22 tests pass and tsc --noEmit is clean.
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