walk models directory

This commit is contained in:
Drew Fyock
2013-09-27 23:37:20 -04:00
parent 612b014e47
commit e230ea224e

View File

@@ -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