aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/app.js
blob: 5bc039dd6b44ebfe188f2aad487d70fb124b52c3 (plain) (tree)
1
2
3
4
5
6
7
8
9





                                
                        
                                   
 
 

                                         


                    
                                   
                                               


                                                        
 











                                                     
 





                                                   
 
 


         
                                         

 



                    

                                                            
   

 

/**
 * Module dependencies.
 */

var express = require('express')
    , fs = require('fs')
  , passport = require('passport');


var app = express(); // initiates express

/**
 * App configuration
 */
var port = process.env.PORT || 8000
  , env = process.env.NODE_ENV || 'development'
  , config = require('./config/config')[env]
  , auth = require('./config/middlewares/authorization')
  , mongoose = require('mongoose');

// Bootstrap db connection
mongoose.connect(config.db);


// Bootstrap models
var models_path = __dirname + '/models';
fs.readdirSync(models_path).forEach( function(file) {
    require(models_path + '/' + file);
});

// Bootstrap passport config
require('./config/passport')(passport, config);

/**
 * Express
 */
var app = express();
// express settings
require('./config/express')(app, config, passport);


/**
 * Routes
 */
require('./router')(app, passport, auth);


/**
 * Server initiation
 */

app.listen(port, function() {
    console.log("Express server listening on port " + port);
});