htteepee

Allows for adding middleware layers to Node.js servers

npm install htteepee
12 downloads in the last week
24 downloads in the last month

htteepee

A teepee you can use for adding layers over your Node HTTP servers!

Allows you to easily add middleware layers to your Node.js server.

npm install htteepee

Uses stack but allowing for a very minor simplification in API usage.

Just change:

    var http = require('http');

...to this:

    var http = require('htteepee');

...and add your middleware functions to the beginning of createServer calls (without need for an extra require and wrapping):

http.createServer(require('./middleware')('Hello'), function (req, res) {

    res.end('World!');

}).listen(1337, '127.0.0.1');

Or, if you want to minimize interference with source files even more, you can require your own file containing the baked in middleware:

var http = require('./baked-in-middleware');

http.createServer(function (req, res) {

    res.end('World!');

}).listen(1337, '127.0.0.1');

...and use the createMiddlewareServer method inside the required middleware file:

var http = require('htteepee');
http.createServer = http.createMiddlewareServer(require('./middleware')('Hello '));
module.exports = http;
npm loves you