-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
82 lines (65 loc) · 2.32 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require('dotenv/config');
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const cors = require('cors');
const http = require('http').createServer(app)
const io = require('socket.io')(http)
const passport = require('passport')
const cookieParser = require('cookie-parser')
const session = require('express-session')
const fileUpload = require('./utility/fileUploads')
//--------------------Start of Middleware----------------------//
app.use(bodyParser.json());
app.set('view-engine', 'ejs')
app.use(bodyParser.urlencoded({extended: true}))
/**app.use(cors({
origin: "http://localhost:3000",
credentials: true
}));**/
app.use(session({
secret: process.env.SESSION_SECRET,
resave: true,
saveUninitialized: true,
})
);
app.use(cookieParser(process.env.SESSION_SECRET));
app.use(passport.initialize());
app.use(passport.session());
require('./utility/passportConfig')(passport);
//fileUpload.clearUploadCache()
//--------------------End of Middleware----------------------//
//---------------------Start of Routes-----------------------//
app.use('/', require('./routes/basic'));
app.use('/user', require('./routes/user'));
app.use('/signups', require('./routes/signups'));
app.use('/points', require('./routes/points'));
app.use('/events', require('./routes/events'));
app.use('/sheets', require('./routes/sheets'));
app.use('/globalvariables', require('./routes/globalvariables'));
app.use('/api/events', require('./routes/api/events'));
app.use('/vp', require('./routes/vp'));
app.use(express.static('public'));
//---------------------End of Routes-----------------------//
/**
io.on('connection', socket => {
//console.log('a user connected!')
socket.on('update-sheet-availability', () => {
//console.log("selected")
})
socket.on('disconnect', () => {
//console.log('user disconnected!')
})
}) */
//Run Notification Email Update
//setInterval(notification.EmailNotificationUpdate, parseInt(process.env.NOTIFICATION_UPDATE_INTERVAL));
//Connect to DB
mongoose.connect(
process.env.DB_CONNECTION,
{ useNewUrlParser: true, useUnifiedTopology: true },
() => {
console.log('Connected to DB!');
}
);
http.listen(process.env.PORT, () => console.log('The app is running on localhost:' + process.env.PORT));