Make a middleware based system for non-HTTP stuff

23 views
Skip to first unread message

Kevin Ingwersen (Ingwie Phoenix)

unread,
Jan 15, 2015, 11:42:00 AM1/15/15
to nod...@googlegroups.com
Hey everyone.

Within my app, I have a global event object, so that all components of the app can talk to one another. However, I have linked it to Redis - so I can not use complex data when turning it into JSON. So I decided, that for pure internal use, i’d add a sub-object that runs on middlewares.

Sadly, I couldn’t find any module that would get me booted with making my own middleware based component.

Basically, I have a function that gets called before an important section of the app. This function gets the object „data“. Now, some components from the app want to modify this object and add or change something. So I want to be able to do soemthing like this:

var MyG = require(… module that offers middleware functionality …)
MyG.use(function(data, next) {
// …
next();
});
MyG.use(…)

// Now within my important function:
function(data) {
MyG.run(data);
}

Is there any module that can solve this?

Kind regards, Ingwie.
Reply all
Reply to author
Forward
0 new messages