diff --git a/server.js b/server.js index d17ed0f0f4..f4b94b6988 100755 --- a/server.js +++ b/server.js @@ -23,9 +23,19 @@ var db = mongoose.connect(config.db); //Bootstrap models var models_path = __dirname + '/app/models'; -fs.readdirSync(models_path).forEach(function(file) { - require(models_path + '/' + file); -}); +var walk = function (path) { + fs.readdirSync(path).forEach(function (file) { + var newPath = path + '/' + file; + var stat = fs.statSync(newPath); + if (stat.isFile()) { + require(newPath); + } + else if (stat.isDirectory()) { + walk(newPath); + } + }); +}; +walk(models_path); //bootstrap passport config require('./config/passport')(passport); @@ -43,7 +53,7 @@ var port = config.port; app.listen(port); console.log('Express app started on port ' + port); -//Initializing logger +//Initializing logger logger.init(app, passport, mongoose); //expose app