Comments (8)
Done. Check out example app.
from railway-routes.
This is great stuff, thank you, will let you know if I see any issues.
JB
from railway-routes.
Hey what about multiple middlewares, like I want one to execute first and then the other one, your example show middleware for just one resource route or namespace, what about if I want have authentication for a posts and then after user authenticate then do a loadUser, user my be used for other actions in other controllers without the need to be authenticated first so for example. In regular express:
get('/post', authenticate, loadUser, function(req, res){}) // multiple mws get('/comment', loadUser, function(req, res){}) // one mw
from railway-routes.
express also allows arrays:
get('/post', [authenticate, loadUser], fn)
etc, in fact any number of nested arrays is fine, so that should already work with this module even if not explicitly supported
from railway-routes.
Awesome TJ, I didn't know that!!! is that supported in express 2.5+
Thanks!
from railway-routes.
yup! [foo, bar, baz], [foo, [bar, baz]], [foo, [bar, [baz]] etc, it's all just flattened
from railway-routes.
Wow wow!!, you see thats why I love express even for things I don't even know :)
Thanks TJ!
from railway-routes.
@cayasso of course you can use this awesome feature within router helpers, just pass function or array of functions to any {middleware: ...} param. It also possible to have nested namespaces with middlewares stack.
from railway-routes.
Related Issues (17)
- Issue with invalid controller actions HOT 1
- as option does not work as expected
- Rename the package? HOT 3
- History.md HOT 2
- Rename repository
- Wrong position for route middlewares HOT 2
- path_to for routes with optional parameters doesn't work HOT 1
- api broken
- HTTP PATCH support HOT 1
- How do I set `camelCaseHelperNames` for all namespaces and resources? HOT 1
- Access resource name in handler when using custom controller names. HOT 1
- Undocumented `state` option in `#getParams`
- Order in `only` param matters HOT 2
- How to add a filter in routes like you do in express ? HOT 6
- Allow sub route params to be camel case HOT 1
- Wildcard routes? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from railway-routes.