-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
executable file
·56 lines (36 loc) · 1.38 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* Module dependencies.
*/
var express = require('express') //express - application framework for node
, fs = require('fs') //fs - filesystem libraru
, http = require('http') //http - give me server
, _ = require('underscore') //underscore - some extra JS sugar
, path = require('path'); //http://nodejs.org/docs/v0.4.9/api/path.html
/**
* Main application entry file.
* Please note that the order of loading is important.
*/
var env = process.env.NODE_ENV || 'local' //get the environemnt var or set as development
, config = require('./config/config')[env]; //get config based on the specifed environment
console.log('ENVIRONMENT = ' + env);
// ================================
// === EXPRESS SETUP AND CONFIG ===
// ================================
//Create an express app
var app = express();
// express settings
require('./core/express')(app, config);
//Create the HTTP server with the express app as an argument
var server = http.createServer(app);
//Create the server
server.listen(app.get('port'), function(){
console.log('app.js: Express server listening on port ' + app.get('port'));
});
server.on('close', function(socket) {
console.log('app.js: Server has closed');
});
var twitter = require('./core/twitter')(app, server, config);
// Bootstrap routes
require('./core/routes')(app, twitter);
// expose app as the scope
exports = module.exports = app;