fix: resolve failing tests and type errors across api and shared packages - #140
Open
stooit wants to merge 1 commit into
Open
fix: resolve failing tests and type errors across api and shared packages#140stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
…ages
- auth middleware: fix HTTP-method case-sensitivity in public-routes list
("post" -> "POST") so POST /users is correctly treated as public
- users route: add missing badRequest import (was ReferenceError -> 500)
- shared types: rename User.userName -> username for consistency with
api usage and tests
- pagination util: implement the paginate() stub
- tsconfig: add bun-types so bun:test and globals type-check
bun test: 22 pass / 0 fail; bunx tsc --noEmit: 0 errors
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 failing tests and TypeScript errors in the bun-workspace repo. Before:
bun testreported 9 fail / 13 pass andbunx tsc --noEmitreported 14 errors. After: 22 pass / 0 fail and 0 type errors.Changes
packages/api/src/middleware/auth.ts"post"vs uppercasec.req.method). Changed["GET", "post"]→["GET", "POST"]soPOST /usersis correctly public (was returning 401 instead of 201).packages/api/src/routes/users.tsbadRequestimport from../lib/errors. It was referenced but not imported, causing aReferenceError(500 instead of the expected 400 on missing fields).packages/shared/src/types.tsUser.userName→usernameto match how the api package and the tests use the field. Consumers viaOmit<User, ...>pick this up automatically.packages/shared/src/utils/pagination.tspaginate()stub (slice +total/totalPages/page/pageSize), matching thePaginatedResponse<T>shape the tests expect.tsconfig.json"types": ["bun-types"]sobun:testimports and runtime globals type-check.bun-typeswas already a declared devDependency — no new dependency added.Verification
bun test→ 22 pass, 0 failbunx tsc --noEmit→ exit 0, zero errorsreviewsubagent: approved, field rename confirmed complete (no strayuserNamein source), no test files or dependency manifests touched.Constraints honoured
package.json/ lockfile change).Assumptions / notes
userName→username) was chosen because the tests referenceusernameand cannot be modified, so the shared type had to conform.paginate()does not guardpage < 1/size === 0;POST /usersis a public write endpoint and the token check uses a non-constant-time comparison with a hardcoded fallback. These appear to be deliberate scaffolding for the test corpus. TheREADME.md"Known issues" list was left intact for the same reason.