Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
walk models directory
Browse files Browse the repository at this point in the history
  • Loading branch information
fyockm committed Sep 28, 2013
1 parent 612b014 commit e230ea2
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down

0 comments on commit e230ea2

Please sign in to comment.