Enhance route parsing to support dynamic paths using AST #5
+367
−15
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.
This pull request significantly improves the route parsing logic to support more dynamic and expressive route definitions in Hono applications. The changes introduce an AST-based parser that can resolve routes defined with constants, string concatenation, and template literals (including variables and mixed expressions), making the extension much more robust and accurate. The documentation and test coverage have also been updated to reflect and verify these new capabilities.
Route Parsing Improvements:
routeParser.tsthat supports extracting routes defined as string literals, constants, string concatenations, and template literals with variables or mixed expressions. This includes logic for resolving constants and evaluating binary expressions for concatenation. [1] [2] [3]Documentation Updates:
README.mdto describe the new supported patterns, including constants, concatenations, and template literals, and clarified unsupported cases.Testing Enhancements:
routeParser.test.tsto cover routes defined using constants, string concatenation, template literals (with and without variables), mixed expressions, and to ensure comments are properly ignored.Type Inference Consistency:
typeInference.tsto use the newresolveRoutePathExpressionlogic, ensuring that type inference works with the expanded set of supported route definitions. [1] [2]