middleware-generic
Simple module that implements the middleware pattern.
Think of it as a mix between EventEmitter
and express
.
This is useful for implementing plugin systems.
API
-
use([namespace ,]handler[,...handlers])
: Pushes a handle into the stack. If you want a middleware that always gets executed you don't need to specify the string. -
handle(namespace[,...args])
: Runs a set of handlers which match the given namespace. -
on(event, callback)
: The middleware inherits from theEventEmitter
prototype. The only even available is theerror
event, which is emitted whenever an error is caught when executing the middlewares.
Example
var m = m m m m m m m