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
Picker is an easy to use server side router for Meteor. This router respect others. So, you can use Iron Router and other routers and middlewares along side with this.
next is optional and call it, if you don't need to handle the current request
Filtering and Sub Routes
This is an unique functionality of this router. See following example:
Let's say we need to handle only POST requests. This is how you can do it with Picker.
varpostRoutes=Picker.filter(function(req,res){// you can write any logic you want.// but this callback does not run inside a fiber// at the end, you must return either true or falsereturnreq.method=="POST";});postRoutes.route('/post/:id',function(params,req,res,next){// ...});
You can create any amount of sub routes with this filter API. Same time, you can create nested sub routes as well.
Middlewares
You can use existing connect and express middlewares without any issues.
// You can use the meteorhacks:npm package to load in the body-parser package// via NPM.varbodyParser=Meteor.npmRequire('body-parser');// Add two middleware calls. The first attempting to parse the request body as// JSON data and the second as URL encoded data.Picker.middleware(bodyParser.json());Picker.middleware(bodyParser.urlencoded({extended: false}));