Skip to content

Conversation

@amitksingh0880
Copy link

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:

  • Added an AST-based parser in routeParser.ts that 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]
  • Updated the fallback regex-based parser to work alongside the AST parser for backward compatibility and as a safety net.

Documentation Updates:

  • Expanded the "Supported route syntax" section in README.md to describe the new supported patterns, including constants, concatenations, and template literals, and clarified unsupported cases.

Testing Enhancements:

  • Added comprehensive test cases in routeParser.test.ts to 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:

  • Refactored typeInference.ts to use the new resolveRoutePathExpression logic, ensuring that type inference works with the expanded set of supported route definitions. [1] [2]

…onstants, concatenation, and template literals, with updated documentation.
@usualoma
Copy link
Member

Hi @amitksingh0880, thank you for creating the pull request.
My apologies, I missed it. I'll review it now, so please bear with me for a moment.

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.

2 participants