Skip to content

mhagmajer/server-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Aug 27, 2020
d98082b · Aug 27, 2020

History

17 Commits
Mar 5, 2018
Mar 5, 2018
Mar 5, 2018
Aug 27, 2020
May 17, 2017
Mar 5, 2018
May 17, 2017
Mar 5, 2018
Aug 27, 2020
May 17, 2017
Mar 5, 2018
May 17, 2017
May 17, 2017
Aug 27, 2020
Aug 27, 2020
May 17, 2017

Repository files navigation

mhagmajer:server-router

Server router with authentication for Meteor

Introductory blog post: https://blog.hagmajer.com/server-side-routing-with-authentication-in-meteor-6625ed832a94.

Documentation: https://mhagmajer.github.io/server-router/.

Compatibility

Please beware that:

  • versions 1.2.x and above require Meteor 1.6.1+
  • versions 1.1.x and below require Meteor 1.4.4.2-1.6

Installing

meteor add mhagmajer:server-router

You can find Flow type definitions in /definitions.

Example

Server-side

import { ServerRouter } from 'meteor/mhagmajer:server-router';

WebApp.connectHandlers.use(ServerRouter.middleware({
  paths: [],
  routes: {
    hello(name) {
      this.res.end(`You ${name}, your id is ${this.userId}`);
    },
  },
}));

Client-side

import { ServerRouterClient } from 'meteor/mhagmajer:server-router';

const serverRouterClient = new ServerRouterClient({
  routes: {
    hello: 1,
  },
});

<Button onClick={() => {
  serverRouterClient.redirect.hello('John');  
}} />

Publishing (contributors)

Run npm run clean before meteor publish.

Releases

No releases published

Packages

No packages published