Last active
February 28, 2022 03:59
-
-
Save lsongdev/c22fe85190186e336e00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/** | |
* [exports Kelp] | |
* @return {[type]} [description] | |
*/ | |
function Kelp() { | |
/** | |
* [app http server handler] | |
* @param {[type]} req [request] | |
* @param {[type]} res [response] | |
* @return {[type]} [undefined] | |
*/ | |
function app(req, res) { | |
var self = this, i = -1, mw; | |
(async function next(err) { | |
mw = app.stack[++i]; | |
return mw && mw.call(self, req, res, next, err); | |
})(); | |
}; | |
/** | |
* [stack middlewares] | |
* @type {Array} | |
*/ | |
app.stack = []; | |
/** | |
* [function push middleware to stack] | |
* @param {[type]} middlewares [middlewares] | |
* @return {[type]} [application] | |
*/ | |
app.use = function (middlewares) { | |
this.stack = [].concat.apply(this.stack, arguments); | |
return app; | |
}; | |
/** | |
* expose | |
*/ | |
return app.use.apply(app, arguments); | |
}; | |
module.exports = Kelp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment