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

Commit

Permalink
Merge pull request #92 from fyockm/walk
Browse files Browse the repository at this point in the history
walk models directory
  • Loading branch information
amoshaviv committed Sep 29, 2013
2 parents 612b014 + e230ea2 commit f5f4663
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 f5f4663

Please sign in to comment.