Deprecated!
This module's functionality has been moved into http-router-fn and mw-compose.
Simpleware
Tiny, simple, Middleware and Routing tool.
Install: npm install simpleware
mw
takes any number of arguments. Each argument must be a handler, or an array of handlers. Handlers will be run sequentially until one does not call next
.
Using the middleware functionality:
var http = ;var mw = mw; var middlewareKit = cookieParser { requser = ; ; }; var app = ; http;
Router
has minimal req
changing functionality built-in.
Using Router
:
var http = ; var app = ;app; // Shortcuts for common methodsapp;app; // Or use any method // Regex handler matches are saved as req.paramsapp; // req.path and req.query are parsed from req.urlapp; // Any handlers that could be put into mw also work hereapp; http;
Router
and mw
can be used in combination:
var http = ;var simpleware = ;var mw = simplewaremw; var router = simpleware;router; http;
Caveats:
- Do not accidentally call a
next()
function more than once in the same handler. It will cause strange behavior like handlers being called out of order or too many times.