Hey Guys,


My name is Gabor and I started learning JavaScript, Node.js with Express 
last December. My problem is I don’t know anybody who works with it. So I 
thought I can ask some questions here. I hope I’m not wrong here!


I hope you understand my questions because I’m from switzerland and I’m not 
so good with grammer :).


My question at the moment is simple. I saw in many code examples that they 
bootstrap the models and sometimes the controllers. This code looks then 
like this.


//Bootstrap models

var models_path = __dirname + '/app/models';

var walk = function(path) {

    fs.readdirSync(path).forEach(function(file) {

        var newPath = path + '/' + file;

        var stat = fs.statSync(newPath);

        if (stat.isFile()) {

            if (/(.*)\.(js$|coffee$)/.test(file)) {

                require(newPath);

            }

        } else if (stat.isDirectory()) {

            walk(newPath);

        }

    });

};

walk(models_path);


// Bootstrap controllers

var controllers_path = __dirname + '/app/controllers'

  , controller_files = fs.readdirSync(controllers_path)

controller_files.forEach(function (file) {

  require(controllers_path+'/'+file)(app)

})



Is there any reason why I should do the same?

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to