Repository navigation
Conversation
Member
|
Why are we doing this? |
Collaborator
Author
Because now the route annotations are very different from the file paths to the routes. Currently given such a route: However, for the catch-all URLs, the syntax is kinda obscure — the generated type for The goal here is to match what users see in the file directory for better readabilty. |
This branch has not been deployed
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.
Background
I messed up when I first added
routeUrlin #640, the internal route type follows Hono's syntax, but that's not what users see when they create file-based routes.Developers naturally expect to reuse the parameter patterns they see in filenames:
routes/api/users/[id].tsfetch('/api/users/[id]', …)routes/files/[...path].tsrouteUrl('/files/[...path]', …)routes/chat/[room].ws.tsconnect('/chat/[room]', …)users/[id].server.tsaction('/users/[id]?update', …)The named catch-all was especially awkward:
The inconsistency also affected types: a page named
users/[id]couldn’t use that same pattern directly withuseParams<'/users/[id]'>()orPageParams<'/users/[id]'>.To stop this problem before it becomes too widespread, we should add support for file-based route patterns while still allowing Hono syntax for now, then deprecate the Hono syntax in a v2 release or something.
Summary
Support bracket route patterns such as
/users/[id]and/docs/[...slug]across generated route types, URL construction, typed HTTP and streaming clients, WebSockets, and page actions. Keep existing generated keys available for compatibility and preserve their inferred contracts.Update public examples and agent guidance to use bracket patterns. Add regression coverage for parameter encoding, catch-alls, named actions, generated/package declarations, all four adapters, browsers, and Workers.
Validation:
vp run checkvp run buildvp test run— 16,185 passed, 32 skipped (781 files passed, one skipped)vp run --filter ./docs build