tilt-router
Class based HTTP router
Compatible with Express 4, Hapi or simple HTTP server.
Lightweight, has only debug and path-to-regexp dependencies.
This module is a follow-up to ES6 Class based Express routing blog post.
Installation
npm install mklabs/tilt-router -S
Usage
Instead of writing app.get('/', function() {});
or server.router({ method: 'GET', path: '/', handler: function() {}})
to define request handlers, you use
a Class to hold methods registered as route handlers to the underlying
framework, Express or Hapi.
Additionnaly, it implements a simple routing mechanism with raw HTTP server.
{ '/': 'index' } { console; return res; }
Express
var app = ;var router = app;app;
Or
var app = ;app;app;
Standard http server
var router = ;router;
Or
var http = ;http;
Or
Router;
Or
Router;
Documentation
Router
API
Router.createServer().
Router;
Router.listen().
Router;
Router.create().
var router = Router;assert;
Router.dispatch() - express middleware.
app;
Router.dispatch() - HTTP server.
http;
App extends Router.
{ return '/': 'index' ; } { return res; }var app = ;app;
HTTP response
GET /.
;
var server = TestApp; ;