Route66
Route66 is a router middleware inspired by Rails for Koa and Express (and any other app or framework).
How is it different?
It is designed to suit medium and big Node.js apps, with ability to customize the way requests are dispatched.
Route66 provides a great API for readable and comfortable definitions of routes.
Route66 can adapt to every project structure out there by letting you decide how request should be handled.
To better understand the idea behind this project, check out this example:
var Router = ;var express = ; var router = ;var app = ; router; router; app;
Features
- Flexible (allows you to handle the request the way you want)
- Lightweight (189 sloc, commented and understandable code)
- Convenient API for defining routes
- Compatible with Koa and Express (and any other custom framework or app)
- Extensive tests
- Support for route parameters
Very soon:
- Support regular expressions
Installation
Install via npm:
$ npm install route66 --save
All-in-one example
Website with a full documentation will be created soon.
var Router = ; var router = ; router;
Dispatching requests in Express apps
var Router = ;var express = ; var router = ;var app = ; router; router; app;
Dispatching requests in Koa apps
var Router = ;var koa = ; var router = ;var app = ; router; router; app;
Dispatching requests in custom apps
Use .resolve(method, url)
to get a correct route for this request:
{ let route params = router; // custom handling}
Tests
Note: You must have Node.js v0.11.x installed.
To run tests, execute this:
$ npm test
License
Route66 is released under the MIT license.