forked from ulrichson/zoomood
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
43 lines (34 loc) · 917 Bytes
/
app.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
/**
* Module dependencies.
*/
var express = require('express'),
mongoose = require('mongoose'),
newrelic = require('newrelic'),
env = process.env.NODE_ENV || 'development',
fs = require('fs'),
http = require('http'),
config = require('./config/config')[env];
/**
* Main app.
*/
// App
var app = express();
// DB
mongoose.connect(config.db);
// Bootstrap models
var models_path = __dirname + '/app/models'
fs.readdirSync(models_path).forEach(function (file) {
if (~file.indexOf('.js')) require(models_path + '/' + file)
})
// Config
require('./config/express')(app, config);
require('./config/upload')(app, config);
require('./config/routes')(app);
// Server
var server = http.createServer(app);
// Socket.io
require('./config/socket')(server);
// Start server
server.listen(app.get('port'), function() {
console.log("Express server listening on port " + app.get('port'));
});