node-libr3

0.1.2 • Public • Published

node-r3

node-r3 is a native binding of c9s/r3 routing library, please check it for more information.

Installation

$ npm install node-libr3

Testing

$ npm test

Benchmarking

$ npm run benchmark

Examples

API

r3 = require("node-libr3");
 
n = new r3.Tree(10);
route_data = 3;
 
n.insert("/bar", route_data);
n.insert("/zoo", route_data);
n.insert("/foo/bar", route_data);
n.insert("/post/{id}", route_data);
n.insert("/user/{id:\\d+}", route_data);
 
n.compile();
 
//should be 3
console.log(n.match("/foo/bar"));

Routing with conditions

r3 = require("node-libr3");
 
n = new r3.Tree(10);
route_data = 3;
 
n.insertRoute(r3.METHOD_GET | r3.METHOD_POST, "/blog/post", route_data);
n.compile();
 
e = new r3.MatchRoute("/blog/post");
//e.requestMethod is r3.METHOD_GET by default
e.requestMethod = r3.METHOD_GET;
 
//should be 3
console.log(n.matchRoute(e));

Alternative

There is another othree/node-r3 project use different approach to let node can use r3's feature.

License

This software is released under MIT License.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.2
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.2
    1
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i node-libr3

Weekly Downloads

1

Version

0.1.2

License

MIT

Last publish

Collaborators

  • caasi