forked from shobhit-pathak/cs2-rcon-panel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
44 lines (34 loc) · 1010 Bytes
/
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
const express = require('express');
const session = require('express-session');
const ejs = require('ejs');
const app = express();
const bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(session({
secret: 'cs2rconpanel',
resave: false,
saveUninitialized: true,
}));
const gameModule = require('./routes/game');
const gameRoutes = gameModule.router;
const serverRoutes = require('./routes/server');
const authRoutes = require('./routes/auth');
const port = 3000;
// Serve static files from the 'public' directory
app.use(express.static('public'));
// Set the view engine to EJS
app.set('view engine', 'ejs');
app.use('/', gameRoutes);
app.use('/', serverRoutes);
app.use('/', authRoutes)
app.get('/', (req, res) => {
if (req.session.user) {
res.redirect('/servers');
} else {
res.render('login');
}
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});