Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.route() grouping breaks trigger event routes. #1

Closed
NamesMT opened this issue Mar 22, 2024 · 2 comments
Closed

.route() grouping breaks trigger event routes. #1

NamesMT opened this issue Mar 22, 2024 · 2 comments

Comments

@NamesMT
Copy link
Owner

NamesMT commented Mar 22, 2024

Trigger event routes/paths support works as a simple wrapper that gets the eventSource, and transforms it into method:TRIGGER path:eventSource Request for Hono to process, we would then register routes on TRIGGER method.
For it to work perfectly, the paths of the eventSource should never intended to be prefixed, i.e: TRIGGER method should never be prefixed

Currently Hono doesn't provide any (and I can't find hack-able) way to get or skip the prefix of .route() grouping, so, Hono instances with trigger events would break after getting grouped with .route()

@NamesMT
Copy link
Owner Author

NamesMT commented Mar 22, 2024

Some possible solutions:

  • Solution 1: update to Hono's core, providing some way to get/skip the prefix of .route() grouping for specific routes/methods.
  • Solution 2: Agree to never use path delimiter "/" in eventSource, we could then provide a helper function to loop through the top-level app.router.routes and just return the string after the last "/" on TRIGGER method, we only need to run it once.
  • Solution 3: A helper function that receives both the top-level app instance and the instance that contains the trigger event routes, would automatically detect and remove the prefixed path, we need to pass in all instances that registered the trigger event routes, also a bit high count of loops and search.
  • Solution 4: Register the trigger event routes in a separate instance and route() them without a prefix, this increases the instances and export/import count.

@NamesMT
Copy link
Owner Author

NamesMT commented Mar 28, 2024

Solved in e834b15

@NamesMT NamesMT closed this as completed Mar 28, 2024
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

No branches or pull requests

1 participant