-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
45 lines (37 loc) · 1.22 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
const express = require('express');
const mongoose = require('mongoose');
const app = express();
const path = require("path");
const keys = require("./app/config/keys");
const cookieSession = require("cookie-session");
const passport = require("passport");
const bodyParser = require('body-parser');
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, './app/views'));
app.set('public', path.join(__dirname, './app/public'));
require('./app/models/User');//should come before passport
require('./app/models/Player');
require('./app/models/Squad');
require('./app/models/PlayerStats');
require('./app/models/UserPlayers');
require('./app/services/passport');
mongoose.connect(keys.mongoose.uri);
//Enabling Cookies
app.use(
cookieSession({
maxAge : 30*24*60*60,
keys : [keys.cookieSession.key]
})
);
//Asking passport to use cookies
app.use(passport.initialize());
app.use(passport.session());
app.use(bodyParser.json());
require('./app/routes/authentication')(app);
require('./app/routes/cricketApi')(app);
require('./app/routes/fantasy')(app);
require('./app/routes/home')(app);
port = process.env.PORT || 8008;
app.listen(port, function () {
console.log("Server serving on " + port+"...");
});