Flow Router Map (Addon package)


#1

Just thought I’d share a very simple addon package I’ve created for Flow Router.

The API was mostly inspired by Django urls and also some of you might remember early Iron Router had a similar pattern for defining routes.

It basically allows you to define your urls like so:

FlowRouter.map(route => {
  route('/', Routes.main);
  route('/archive', Routes.archive);
  route('/add', Routes.add);
  route('/edit/:_id', Routes.edit);
  route('/view/:_id', Routes.view);
});

The nice thing about this is that you are then free to organise your route logic across many files while still retaining visibility of your paths across your entire application.

For example you might then setup your routes like:

lib/routes.js – Contains your url map along with routes on the root prefix
lib/routes/products.js – Routes for /products/* route group
lib/routes/categories.js – Routes for /categories/* route group

Interested to hear any further ideas on other approaches to organising routes on larger apps.

Here’s the package: https://atmospherejs.com/dburles/flow-router-map


#2

I like the idea, it’s one of the features from Symfony router that I missed a lot. Thanks for the package!