-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapp.js
More file actions
43 lines (33 loc) · 1.05 KB
/
app.js
File metadata and controls
43 lines (33 loc) · 1.05 KB
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
//Modules used.
var express = require('express')
, fs = require('fs')
, passport = require('passport')
, config = require('./config/config')
//Set up database
var mongoose = require('mongoose')
mongoose.connect(config.db)
var db = mongoose.connection
db.on('error', function () {
throw new Error('unable to connect to database at ' + config.db)
})
//Bootstrap models.
var modelsPath = __dirname + '/app/models'
fs.readdirSync(modelsPath).forEach(function (file) {
if (file.indexOf('.js') >= 0) {
require(modelsPath + '/' + file)
}
})
//Bootstrap passport
require('./config/passport')(passport, config)
//Bootstrap express
var app = express()
require('./config/express')(app, config, passport)
//compatible with heroku
var port = process.env.PORT || config.port;
var server = app.listen(port)
var io = require('socket.io').listen(server);
var streamable = require('streamable').streamable(io);
console.log("Server listening on port " + port)
//Bootstrap routes.
require('./config/routes')(app, passport, streamable)
exports = module.exports = app