fix(nodejs): narrow required route parameters#125
Open
ShuoRen-TT wants to merge 1 commit into
Open
Conversation
1116fd9 to
952b0fd
Compare
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
IdParamContextfrom the existingIdParamSchemac.req.valid("param")in checkout, order, and simulation handlersstring | undefinedTypeScript errors without non-null assertions or duplicate validationRoot cause
The route handlers were declared with a generic Hono
Context, soc.req.param("id")was typed asstring | undefined. Although every affected route already useszValidator("param", IdParamSchema, ...), that validated input type did not flow into the separately declared class handlers.This change makes the handler context carry the Zod-derived parameter input/output type and consumes the value from Hono's validated request data.
Validation
GET /items/item-123returned200with{"id":"item-123"}npm run builderrors are the 8 discovery-profile errors fixed by fix(nodejs): align discovery profile registries #123npm run build: passednpm test: passed, 3/3 testsRelated work
This PR is independently mergeable and fixes all route-parameter typing
errors. The current main branch still has separate discovery-profile type
errors tracked by #114 and fixed by #123. With both changes present,
npm run buildandnpm testpass.Closes #124