-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
54 lines (40 loc) · 1.73 KB
/
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
44
45
46
47
48
49
50
51
52
53
// define globals
var server_port = process.env.OPENSHIFT_NODEJS_PORT || 8080
var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1'
var express = require('express');
var app = express();
var mongoose = require('mongoose');
var passport = require('passport');
var flash = require('connect-flash');
var morgan = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var session = require('express-session');
var FacebookStrategy = require('passport-facebook').Strategy;
var http = require('http').Server(app);
var io = require('socket.io')(http);
// Passport
require('./config/passport.js')(passport);
// set up our express application
app.use(morgan('combined')); // log every request to the console
app.use(cookieParser()); // read cookies (needed for auth)
app.use(bodyParser.json()); // get information from html forms
app.use(bodyParser.urlencoded({ extended: true }));
app.set('view engine', 'ejs'); // set up ejs for templating
app.set('views', __dirname + '/app/views');
// required for passport
app.use(session({ secret: '31aa12a5dd38d9554192aa5ad7bc1ffcade950cf' })); // session secret
app.use(passport.initialize());
app.use(passport.session()); // persistent login sessions
app.use(flash()); // use connect-flash for flash messages stored in session
// App
require('./app/routes.js')(app,passport);
// set up our socket server
require('./sockets/base')(io,passport);
// DB setup...
var configDB = require('./config/database.js');
mongoose.connect(configDB.url); // connect to our database
// start the server
http.listen(server_port, server_ip_address, function () {
console.log( "Listening on " + server_ip_address + ", server_port " + server_port )
});