Package Exports
- en-route
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (en-route) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
en-route 
Routing for static site generators, build systems and task runners, heavily based on express.js and kerouac routes.
Install
Install with npm
npm i en-route --save
API
proto
- {Object}: options
returns
{Router}: which is an callable function
Initialize a new Router
with the given options
.
.param
Map the given param placeholder name
(s) to the given callback.
name
{String}fn
{Function}returns
{app}: for chaining
Parameter mapping is used to provide pre-conditions to routes which use normalized placeholders. For example a :user_id parameter could automatically load a user's information from the database without any additional code,
The callback uses the same signature as middleware, the only difference
being that the value of the placeholder is passed, in this case the id
of the user. Once the next()
function is invoked, just like middleware
it will continue on to execute the route, or subsequent parameter functions.
app.param('user_id', function(file, next, id) {
User.find(id, function(err, user) {
if (err) {
return next(err);
} else if (!user) {
return next(new Error('failed to load user'));
}
file.user = user;
next();
});
});
.use
Use the given middleware function, with optional path, defaulting to "/".
fn
{Function}
The other difference is that route path is stripped and not visible to the handler function. The main effect of this feature is that mounted handlers can operate without any code changes regardless of the "prefix" pathname.
.route
Create a new Route for the given path.
- {String}: path
returns
: {Route}
Each route contains a separate middleware stack.
See the Route api documentation for details on adding handlers and middleware to routes.
Author
Jon Schlinkert
Brian Woodward
License
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
Based on previous work by:
Copyright (c) 2009-2014 TJ Holowaychuk tj@vision-media.ca Copyright (c) 2012-2013 Jared Hanson http://jaredhanson.net/
This file was generated by verb-cli on November 02, 2014.