0.1.2 • Published 11 years ago

path-finder v0.1.2

Weekly downloads
3
License
-
Repository
github
Last release
11 years ago

Pathfinder

Simple named routes for Express.

Usage

  1. Install via npm

    $ npm install path-finder
  2. Extend your Express app

    var express = require('express');
    var app = express();
    require('path-finder').extend(app);
  3. Profit

    // Standard Express routing does not change
    app.get('/users', function(){...})
    
    // Passing in a name stores the path
    app.get('/home', 'home', function(){...})
    app.post('/user/:id', 'user', function(){...});
    
    // Paths can be accessed via
    app.path('home');           //-> '/home'
    app.path('user', {id: 10}); //-> '/user/10' 
    
    // Passing in additional options adds them to the query string
    app.path('home', {p: 1});   //-> '/home?p=1'
    
    // Ad-hoc paths can also be defined
    app.addPath('/promotions', 'promotions');
    app.path('promotions');     //-> '/promotions'

    A p method is also made available to views

    a(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
0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago

0.0.1

11 years ago