mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-23 23:59:17 +01:00
walk models directory
This commit is contained in:
18
server.js
18
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
|
||||
|
||||
Reference in New Issue
Block a user