meteorhacks/picker

Name: picker

Owner: meteorhacks

Description: Server Side Router for Meteor

Created: 2014-12-15 08:22:43.0

Updated: 2018-03-24 23:21:04.0

Pushed: 2018-03-21 06:44:57.0

Homepage: null

Size: 13

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Picker - Server Side Router for Meteor

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.

Install
or add meteorhacks:picker
Getting Started
er.route('/post/:_id', function(params, req, res, next) {
r post = Posts.findOne(params._id);
s.end(post.content);

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.

postRoutes = 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 false
turn req.method == "POST";


Routes.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.

ou can use the meteorhacks:npm package to load in the body-parser package
ia NPM.
bodyParser = Meteor.npmRequire( 'body-parser');

dd two middleware calls. The first attempting to parse the request body as
SON data and the second as URL encoded data.
er.middleware( bodyParser.json() );
er.middleware( bodyParser.urlencoded( { extended: false } ) );

You can use middlewares on sub routes as well.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.