-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
40 lines (33 loc) · 1 KB
/
Copy pathserver.js
File metadata and controls
40 lines (33 loc) · 1 KB
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
// Required packages and dependencies
const express = require('express')
const socketIO = require("socket.io");
const {SetUpSocketIo} = require('./routes/chat')
const path=require('path')
const authRoutes = require('./routes/auth')
const mainRoutes = require('./routes/main')
require("dotenv").config();
// Inititated instance of express
const app = express()
// settng up properties of server
app.set("view engine", "ejs")
app.set("views", path.join("./frontend/views"))
app.use(express.static(path.join(__dirname)));
app.use(express.json())
// Listening on dynamic port
const server=app.listen(process.env.PORT,()=>{
console.log("Listening on Port: ",process.env.PORT)
})
app.use(authRoutes)
app.use(mainRoutes)
app.get('/auth',(req,res)=>{
res.render("auth")
})
app.get('/',(req,res)=>{
res.render('home')
})
// Setting up io connection
const io = socketIO(server, {
pingTimeout: 900000, // Set a higher ping timeout (in milliseconds)
})
// Importing socket propeties from the main file
SetUpSocketIo(io)