0.0.9 • Published 6 years ago

track-router v0.0.9

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

TrackRouter

Router for track.

Build Status

Installation

npm

npm install track-router

Usage

const TrackRouter = require('track-router');

TrackRouter.configure(() => {
  get('/', {to: require('homes/index'), as: 'root'}); // `/`

  namespace('hoges', () => {
    get('/',   {to: 'hoges/index', as: 'index'}); // `/hoges`
    get(':id', {to: 'hoges/show',  as: 'show'});  // `/hoges/:id`

    namespace('fugas', () => {
      get(':id', {to: 'hoges/fugas/show',  as: 'show'}); // `/hoges/fugas/:id`
    });
  });

  namespace('foo', () => {
    namespace(':id', () => {
      get('/bar', {to: 'foo/bar/index', as: 'bar'}); // `/foo/:id/bar`
    });
  });

  get('/numbers/:num', {to: 'numbers/show', as: 'numbers', constraints: {num: /^\d+$/}})
});

TrackRouter.getPath('root');                 // `/`
TrackRouter.getPath('hoges_show', {id: 777}) // `/hoges/777`
TrackRouter.getPath('foo_bar',    {id: 888}) // `/foo/888/bar`
0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago