-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
61 lines (49 loc) · 1.67 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
const express = require('express');
const dotenv = require('dotenv');
const cors = require('cors');
const bodyparser = require('body-parser');
const session = require('express-session');
const { v4: uuidv4 } = require('uuid');
dotenv.config();
const app = express();
const socket = require('socket.io');
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.text());
app.use(cors());
/** Static files */
app.use(express.static('public'));
app.use('/css', express.static(__dirname + 'public/css'));
app.use('/img', express.static(__dirname + 'public/img'));
app.use('/js', express.static(__dirname + 'public/js'));
app.use(session({
secret: uuidv4(),
resave: false,
saveUninitialized: true
}));
/** Template Engine */
app.set('views', './src/views');
app.set('view engine', 'ejs');
/** Routs */
const { loginRouter, logoutRouter } = require('./src/routes/login');
app.use('/login', loginRouter);
app.use('/logout', logoutRouter);
//app.use('/user/login', loginRouterP);
const dashRouter = require('./src/routes/dashbourd');
app.use('/dashbourd', dashRouter);
const userRouter = require('./src/routes/user');
app.use('/dashbourd/user', userRouter);
const adminRouter = require('./src/routes/admin');
app.use('/dashbourd/admin', adminRouter);
const statRouter = require('./src/routes/static');
app.use('/dashbourd/stats', statRouter);
const apiRouter = require('./src/routes/api');
app.use('/api', apiRouter);
/** App start */
const server = app.listen(process.env.PORT, () => {
console.log(`Listening on port: ${process.env.PORT}`);
});
const io = socket(server);
io.on("connection", function(socket) {
console.log("Made socket connection");
});