-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
77 lines (67 loc) · 2.95 KB
/
server.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
require('dotenv').config()
const express = require('express'),
mongoose = require('mongoose'),
passport = require('passport'),
app = express(),
flash = require('express-flash'),
session = require('cookie-session'),
PORT = process.env.PORT || 5000,
passportInit = require('./utils/passport-config'),
{ensureAuthenticated, forwardAuthenticated} = require('./utils/authenticate')
const indexRouter = require('./routers/indexRouter'),
regRouter = require('./routers/regRouter'),
loginRouter = require('./routers/loginRouter'),
adminRouter = require('./routers/adminRouter'),
hackSubRouter = require('./routers/hackSubRouter'),
itemsRouter = require('./routers/shopRouter'),
hackRegRouter = require('./routers/hackReg'),
logoutRouter = require('./routers/logoutRouter'),
snakeRouter = require('./routers/snakeRouter'),
lbRouter = require('./routers/lbRouter'),
faqRouter = require('./routers/faqRouter')
breachPRouter = require('./routers/breachPRouter');
mongoose.connect(process.env.MONGO_URI, console.log('MONGODB CONNECTED'))
app.use(express.static('public'))
app.use('/', express.static('public'))
app.use(express.static('uploads'))
app.use('/', express.static('uploads'))
app.set('view engine', 'ejs')
app.use(flash())
app.use(session({
secret: process.env.SESSION_SECRET,
resave: true,
saveUninitialized: true
}))
app.use(express.urlencoded({extended: false}))
app.use(express.json({limit: '1mb'}))
app.use(passport.initialize())
app.use(passport.session())
passportInit(passport)
app.get('/normalTeam', (req, res) => {
const domainName = process.env.DOMAIN_NAME
console.log(domainName)
res.render('normalTeamEmail', {user: req.user, teamName: "X Team", participant1: '[email protected]', participant2: '[email protected]', participant3: null, participant4: null, teamAdmin: "[email protected]", domainName: domainName})
})
app.get('/adminTeam', (req, res) => {
res.render('adminTeamEmail', {user: req.user, teamName: "X Team", participant1: '[email protected]', participant2: '[email protected]', participant3: null, participant4: null, teamAdmin: "[email protected]"})
})
app.use('/', indexRouter)
app.use('/login', forwardAuthenticated, loginRouter)
app.use('/register', forwardAuthenticated, regRouter)
app.use('/admin', ensureAuthenticated, adminRouter)
app.use('/hack', ensureAuthenticated, hackSubRouter)
app.use('/shop', ensureAuthenticated, itemsRouter)
app.use('/hackReg', ensureAuthenticated, hackRegRouter)
app.use('/logout', ensureAuthenticated, logoutRouter)
app.use('/snake', ensureAuthenticated, snakeRouter)
app.use('/breachProtocol', ensureAuthenticated, breachPRouter)
app.use('/lb', ensureAuthenticated, lbRouter)
app.use('/faqs', faqRouter)
app.get('/logout', (req, res) => {
req.logout();
res.redirect('/login');
});
app.use((req, res, next) => {
res.status(404).render('notfound', {user: req.user})
})
app.listen(PORT, console.log(`SERVER CONNECTED ON PORT ${PORT}`))