Skip to content

alinz/trie-route

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yet another router implementation with trie at core

This is a simple implementation of router by using Trie data structure at core. It has a basic param feature for example the following code are valid.

/users/:id
/users/:id/friends

here's an example code:

var route = require('trie-route');

var router = route.create();

router.path('/users/:id', function (params) {
  console.log('this is /users/:id path');
  console.log("here's the list of params", params);
});

router.path('/users/:id/friends', function (params) {
  console.log('this is /users/:id/friends path');
  console.log("here's the list of params", params);
});

var error = router.process('/users/14');
console.log('error:', error);

error = router.process('/users/14/enemies');
console.log('error:', error);

Release Note

0.0.5

  • added opt in router.process(path, opt). opt will be pass to callback as 3rd argument.

About

yet another router implementation with trie at core

Resources

License

Stars

Watchers

Forks

Packages

No packages published