Pathfinder
Simple named routes for Express.
Deprecation Warning
The following methods will print deprecation messages when used as extending the
express 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 path-finder
).
appapp
Usage
-
Install via npm
$ npm install path-finder
-
Extend your Express
app
var express = ;var app = ;var pathFinder = ;pathFinder; -
Profit
// 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'A
p
method is also made available to viewsa(href=p('promotions')) | View our promotions
Development
Clone the repo
$ git clone git@github.com:davidcornu/path-finder.git
Install dependencies
$ npm install
Run the tests
$ npm test