index.js
function(filepath, req, res) {
    var path = require("path"),
        config = module.exports.config,
        result = false,
        parentdir;
    do {
        var defaultdir = path.resolve(path.join(config.responsesdefault, filepath));
        parentdir = path.resolve(path.join(config.responses, filepath));
        if (isValidDir(parentdir) && isValidFile(path.join(parentdir, "index.js"))) {
            //Parent module response handler exists.
            require(parentdir)(req, res);
            result = true;
        } else if (isValidDir(defaultdir) && isValidFile(path.join(defaultdir, "index.js"))) {
            //Default response handler
            require(defaultdir)(req, res);
            result = true;
        }
        if (filepath === path.sep) break;
        filepath = path.dirname(filepath);
    } while (result === false && parentdir !== filepath);
    return result;
}
function(filepath, req, res) {
    var path = require("path"),
        config = module.exports.config,
        result = false,
        parentdir;
    do {
        var defaultdir = path.resolve(path.join(config.responsesdefault, filepath));
        parentdir = path.resolve(path.join(config.responses, filepath));
        if (isValidDir(parentdir) && isValidFile(path.join(parentdir, "index.js"))) {
            //Parent module response handler exists.
            require(parentdir)(req, res);
            result = true;
        } else if (isValidDir(defaultdir) && isValidFile(path.join(defaultdir, "index.js"))) {
            //Default response handler
            require(defaultdir)(req, res);
            result = true;
        }
        if (filepath === path.sep) break;
        filepath = path.dirname(filepath);
    } while (result === false && parentdir !== filepath);
    return result;
}
function ( filepath , req , res ) { var path = require ( "path" ) , config = module . exports . config , result = false , parentdir ; do { var defaultdir = path . resolve ( path . join ( config . responsesdefault , filepath ) ) ; parentdir = path . resolve ( path . join ( config . responses , filepath ) ) ; if ( isValidDir ( parentdir ) && isValidFile ( path . join ( parentdir , "index.js" ) ) ) { //Parent module response handler exists. require ( parentdir ) ( req , res ) ; result = true ; } else if ( isValidDir ( defaultdir ) && isValidFile ( path . join ( defaultdir , "index.js" ) ) ) { //Default response handler require ( defaultdir ) ( req , res ) ; result = true ; } if ( filepath === path . sep ) break ; filepath = path . dirname ( filepath ) ; } while ( result === false && parentdir !== filepath ) ; return result ; }
Join responses root folder to requested sub-directory
id - sub-folder path
req - http request http.IncomingMessage
res - http response http.ServerResponse
Join responses root folder to requested sub - directory id - sub - folder path req - http request http . IncomingMessage res - http response http . ServerResponse