You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to implement a router similar to this one, but with different path matching semantics. Is there any plan to abstract the core logic into an engine module that other implementations can use?
So I, for one, want to make the path syntax pluggable, and I'm not sure if that's in line with what you want. Otherwise, I'm always for more splitting of stuff. What part were you think of?
I haven't yet tried, but it shouldn't be too hard. I definitely intend to make the paths pluggable (more than just providing a RegExp, since req.params cannot have named properties with a RegExp).
@dougwilson Great, I'll see after and during the development what is similar between the modules and we can factor out. I'm also going to be building it with first-class promise support, so I'll need to see where that fits in with this.
Cool. So one thing I'm looking forward to is to see if the "io.js" project causes some more movement within Node.js. Because things like potential ES7 await make not using Promises really dumb :)
@scottcorgan It'll fix the engine issue by allowing your own match function to be used. The implementation using path-to-regexp in index.js is the only documentation right now.
You'll need to implement the methods for .route, .use and #verb that will turn the path into a function instead of a regexp. That function just needs to return an object { path: '/foo', { params: { id: 'foo } } or false if no match.
@dougwilson Cheers for moving away from Express and creating PillarJS! That's what open source means!
For the sake of all - please rewrite this router as it's driving me crazy! I can't understand how in 2016 there's no way to backtrack those paths and you have to hardcode the links in your views.
What I mean is that paths are now anonymous and because of the middleware style of array-like routes, there's no chance to get back and create link for specific route. For example:
<!-- view.html; if using any some kind of templating engine --><ahref="/workspace/{{ workspace.id }}/project/{{ project.id }}/user/{{ user.id }}>link</a>
// not to mention creation of a link via pure js:href="/workspace/"+workspace.id+"/project/"+project.id+"/user/"+user.id
If I want to change workspace to workspaces I have to edit all my views, which will potentially make me die :)
So if you have some spare time - I would love to have this feature, and I'm sure tons of others are needing it too. I would love to contribute, but the more I dive into the Router, the more I'm smashing my head in the wall, as it's so absurd..
@fourpixels Sounds like you should open a new issue that can be tagged as ideas. Your point seems valid, but could probably be fleshed out in its own issue/thread.
Yeah, sorry about that. I just saw a router ideas issue, so I didn't want to mess things around before knowing what you guys think. Will open one next with better description, you can delete my posts here :)
Activity
dougwilson commentedon Jan 13, 2015
So I, for one, want to make the path syntax pluggable, and I'm not sure if that's in line with what you want. Otherwise, I'm always for more splitting of stuff. What part were you think of?
scottcorgan commentedon Jan 13, 2015
I think that making the paths pluggable is a fantastic idea. My specific use case is negated glob-type routes.
dougwilson commentedon Jan 13, 2015
I want URL template-style routes. Not sure if that's what you mean by "glob-style" :)
scottcorgan commentedon Jan 13, 2015
Not sure what you mean by template-style.
By glob-style I mean "!/*/assets/.js"
dougwilson commentedon Jan 13, 2015
Gotcha. URL templates are RFC 6570 (simple example:
/user/{userId}/friends).scottcorgan commentedon Jan 13, 2015
Is it much work to make the paths pluggable?
dougwilson commentedon Jan 13, 2015
I haven't yet tried, but it shouldn't be too hard. I definitely intend to make the paths pluggable (more than just providing a
RegExp, sincereq.paramscannot have named properties with aRegExp).scottcorgan commentedon Jan 13, 2015
Cool. Looking forward to it. Router has become indispensable for us and creating middleware chains.
blakeembrey commentedon Jan 14, 2015
@dougwilson Great, I'll see after and during the development what is similar between the modules and we can factor out. I'm also going to be building it with first-class promise support, so I'll need to see where that fits in with this.
dougwilson commentedon Jan 14, 2015
Cool. So one thing I'm looking forward to is to see if the "io.js" project causes some more movement within Node.js. Because things like potential ES7
awaitmake not using Promises really dumb :)scottcorgan commentedon Jan 23, 2015
So, this is going to be solved by #13?
Any docs on that branch?
blakeembrey commentedon Jan 23, 2015
@scottcorgan It'll fix the engine issue by allowing your own match function to be used. The implementation using
path-to-regexpinindex.jsis the only documentation right now.scottcorgan commentedon Jan 23, 2015
What would that look like?
blakeembrey commentedon Jan 23, 2015
Check out https://github.com/blakeembrey/router/blob/router-engine/index.js
You'll need to implement the methods for
.route,.useand#verbthat will turn the path into a function instead of a regexp. That function just needs to return an object{ path: '/foo', { params: { id: 'foo } }orfalseif no match.fourpixels commentedon Jan 26, 2016
@dougwilson Cheers for moving away from Express and creating PillarJS! That's what open source means!
For the sake of all - please rewrite this router as it's driving me crazy! I can't understand how in 2016 there's no way to backtrack those paths and you have to hardcode the links in your views.
What I mean is that paths are now anonymous and because of the middleware style of array-like routes, there's no chance to get back and create link for specific route. For example:
If I want to change
workspacetoworkspacesI have to edit all my views, which will potentially make me die :)So if you have some spare time - I would love to have this feature, and I'm sure tons of others are needing it too. I would love to contribute, but the more I dive into the Router, the more I'm smashing my head in the wall, as it's so absurd..
wesleytodd commentedon Jan 26, 2016
@fourpixels Sounds like you should open a new issue that can be tagged as
ideas. Your point seems valid, but could probably be fleshed out in its own issue/thread.fourpixels commentedon Jan 26, 2016
Yeah, sorry about that. I just saw a router ideas issue, so I didn't want to mess things around before knowing what you guys think. Will open one next with better description, you can delete my posts here :)