Re:Show HN: Simple express-like routing for front-end
by urvader on Wednesday August 17, 2016 @02:36AM
(#12302869)
Do you plan to support middlewares?
[ Parent
| on HN ]
Re:Show HN: Simple express-like routing for front-end
by franciscop on Wednesday August 17, 2016 @02:44AM
(#12302897)
Could you explain further, please? I plan on changing it a bit internally but not on growing it past its purpose as I like it to do only one thing (and hopefully do it well)
Re:Show HN: Simple express-like routing for front-end
by lcarlson on Wednesday August 17, 2016 @03:00AM
(#12302930)
I think page.js supports middleware if you're looking for something to emulate. Basically chainring callbacks.
Re:Show HN: Simple express-like routing for front-end
by franciscop on Wednesday August 17, 2016 @03:04AM
(#12302943)
Only reference I could find in https://visionmedia.github.io/page.js/ was:
page(callback)
This is equivalent to page('*', callback) for generic "middleware".
Which is... pointless? If you are going to call a function everywhere in front-end why don't you use an IIFE for scope or just nothing at all? Unless you wanted to put it on the <head> and make it load when the page is ready.
Re:Show HN: Simple express-like routing for front-end
by reaktivo on Wednesday August 17, 2016 @03:18AM
(#12302981)
A callback is middleware, you can
page('/some/path', middleware, callback);
Re:Show HN: Simple express-like routing for front-end
by franciscop on Wednesday August 17, 2016 @03:23AM
(#12302998)
I see, but I don't really like this extra functionality for pagex. I am not looking to copy express with middleware for front-end, just wanted some easy and straight way to load a script if we are in the correct part of the website.
Re:Show HN: Simple express-like routing for front-end
by gberger on Wednesday August 17, 2016 @04:43AM
(#12303215)
Uh, then you and I have very different definitions of "express-like". When I think of express I think of middleware.
Re:Show HN: Simple express-like routing for front-end
by franciscop on Wednesday August 17, 2016 @11:46AM
(#12305546)
In the simple way, express accepts a path (url-like fragment) and executes a callback when it matches the url. THAT is what I meant from express-like, but from this and other comments I can see it wasn't clear at all.