Route matching like in express #1120
-
Hi, we're using VPS/Vike at Burdaforward and currently use mulitple express routes that call However, I am not sure this is currently possible due to differences in routing between express and VPS.
This test suggests that the example number 4 currently isn't possible with VPS routing So the main difference seems to be how globs are treated.
The latter happens quite often for us with things like So is it correct that globs followed by other characters is currently not possible? Is there a reason for this restriction? Is anything planned to enable this in the future? Thanks a lot for you help |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 18 replies
-
See c1537dc, let me know whether that works for you. I'm glad BurdaForward is still working on its vite-plugin-ssr project. Let me know if you run into any issues, and feel free to keep me updated how things go. The raison d'etre of vite-plugin-ssr is increased flexibilty and I'm looking forward to further support BurdaForward's use case. On a tangent: is there any chance to get sponsoring up again? This makes a massive difference. I'm trying to make ends meet with sponsoring but, as you can imagine, 33% of the monthly sponsoring goal is very tough. (I basically have to save every penny to make it work.) I'd love continue working full-time on vite-plugin-ssr but I need the help of companies. Thanks for considering it and also thanks for already sponsoring earlier this year. I'm very much looking forward to make it work while consolidating BurdaForward's bet on vite-plugin-ssr. (We can sign a contract ensuring that I'll be working on vite-plugin-ssr for at least X amount of months/years if that's something you'd be interested in. Although, honestly, I love working on vite-plugin-ssr so it's just a matter of securing sponsors.) |
Beta Was this translation helpful? Give feedback.
-
I just checked out the routing functions and it seems like they would let us do what we want. I looked at this particular example and I was wondering the following:
Regarding the sponsoring again: we'll need to discuss this internally of course. We don't currently have any need to additional features I think, but of course we have a vital interest in VPS's ongoing maintenance and development. |
Beta Was this translation helpful? Give feedback.
-
The syntax would not be a problem for us. See we way we currently do things is our framework users specify routes very similar to how it's done it VPS. Here a brief look into to what we do roughly. // some-page/index.route.ts
export const route = "/some/express/:style/route*.html" From that file, we generate a corresponding file which serves as the VPS route string in a pre-build step. While doing this we convert express style routes to VPS style routes. This happens under the hood with the user never knowing about it. So from the above we get. // generated-files/some-page/index.route.ts
export const route = "/some/express/@style/route*.html" // note the @ here that used to be a : We do some extra magic since the globbing in the middle part is not working in VPS yet and basically routing happens twice first in Express and then again in VPS. function route({ pathName }) {
const { match, otherStuff} = pathToRegexp(allRoutes, expressStyleRoute) // call express routing lib
if (!match) return false;
return { routeParams: ... },
} Having a the VPS globbing in the middle would make it even simpler and allow us to not have to use a route function at all. However, it wouldn't be a blocker. That would allow us to
I agree, ensuring and supporting the ongoing support would be the biggest benefit. |
Beta Was this translation helpful? Give feedback.
Just released
[email protected]
which should now work for BurdaForward's globs in the middle use cases.(FYI it turned out to be complex to support all edge cases; a linear processing of the route string doesn't work in some important scenarios, even for only a single glob
*
. To avoid exploding complexity (and therefore bundle size), the route strings are now transformed into a RegExp. The good news is that the new router is now not only much more feature rich regarding globs but also slightly less KBs than the previous implementation.)