-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (38 loc) · 1.08 KB
/
index.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
const app = require("express")();
const express = require("express");
const dbConfig = require("./db/connect");
const path = require("path")
const userRoutes = require("./routes/users");
const paymentRoutes = require("./routes/payment")
const cors = require("cors");
const { Server } = require('socket.io')
const http = require("http");
require("dotenv").config();
dbConfig.connectDb();
// limiting all the acces that comes from other hosting
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.get("/test", (req, res) => {
res.send("LOL EV's wooh");
});
// bringing all the routes
userRoutes.userRoutes(app);
paymentRoutes.paymentRoutes(app)
const server = http.createServer(app)
const io = new Server(server, {
cors: {
origin: "*",
methods: ["GET", "POST"]
}
})
io.on("connect", (socket) => {
console.log('connected')
socket.on("disconnect", () => {
console.log("client disconnected..");
})
})
server.listen(process.env.PORT, () => {
console.log(`App running and connected to port ${process.env.PORT}`);
});
module.exports.Socket = io