Serverside backbone router for express 4. Mostly lifted from Backbone.js.
Part of the Ampersand.js toolkit for building severside applications.
npm install ampersand-express-router
var Router = ;var express = ;var bodyParser = ;var app = ;// parse application/x-www-form-urlencodedapp;// parse application/jsonapp;var UserRouter = Router;var UsersRoute =app: app;app;
Get started by creating a custom router class. Define actions that are triggered when certain URL are matched, and provide a routes hash that pairs routes to actions. Note that you'll want to avoid using a leading slash in your route definitions:
var UserRouter = Router;
The routes hash maps URLs with parameters to functions on your router. Routes can contain path parameter parts,
The before filters hash maps URLs with parameters to functions on your router. Route filters can contain path parameter parts,
constructor / initialize
When creating a new router, you must pass an instance of express application which this router will be mounted into and additional express router options.
All credit goes to Jeremy Ashkenas and the rest of the Backbone.js authors.