route-builder
route-builder
is a simple path matcher and path maker based on path-to-regexp
(same as Express). It is meant to serve as the foundation for a router.
route-builder
borrows on the work of routr and reverend.
Usage
Adding routes
var RouteBuilder = ; // via the constructor var router = 'home' '/' 'post' '/post/:id' a: 1 b: 2 c: 3 'multi_media' '/:type/*anything/:id' ; // via the `add` method router;
Matching
router; //=> true router; //=> false
router; //=> { name: 'post', meta: {a: 1, b: 2, c: 3}, params: {id: '123'}} router; //=> null
Make path
router; //=> '/post/456' // missing required params router; //=> null // non-existing route router; //=> null