Named routes for Express.
Simple named routes for Express.
The following methods will print deprecation messages when used as extending the
app variable is error prone and doesn't really provide a better interface,
especially when calling routes from controllers (
req.app.p('login') is a lot
more verbose than simply requiring
Install via npm
$ npm install path-finder
Extend your Express
var express = ;var app = ;var pathFinder = ;pathFinder;
// Standard Express routing does not changeapp// Passing in a name stores the pathappapp;// Paths can be accessed viapathFinder; //-> '/home'pathFinder; //-> '/user/10'// Passing in additional options adds them to the query stringpathFinder; //-> '/home?p=1'// Ad-hoc paths can also be definedpathFinder;pathFinder; //-> '/promotions'
p method is also made available to views
a(href=p('promotions'))| View our promotions
Clone the repo
$ git clone email@example.com:davidcornu/path-finder.git
$ npm install
Run the tests
$ npm test