-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
43 lines (38 loc) · 1.11 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
const http = require("http");
const express = require("express");
// const app = express();
require("events").EventEmitter.prototype._maxListeners = 100;
const app = require("./app");
var cors = require("cors");
const userRouterFile = require("./api/routes/users");
const taskRouterFile = require("./api/routes/task");
///cors issuenpm start
app.use(
cors({
origin: "*",
})
);
app.use(express.json({ limit: "50mb" }));
app.use(express.urlencoded({ extended: false, limit: "50mb" }));
const server = http.createServer(app);
const io = require("socket.io")(server, {
cors: {
origin: "*",
// origin: 'https://www.helpros.app/api/',
// methods: ['GET', 'POST', 'PUT', 'DELETE'],
// credentials: true,
},
});
userRouterFile.userRouter(io);
taskRouterFile.taskRouter(io);
io.on("connection", (socket) => {
console.log("New client connected");
socket.on("disconnect", () => {
console.log("Client disconnected");
});
});
const port = process.env.port || 6002;
server.listen(port, () => {
console.log(`Server Started At PORT : ${port} {Ansa Media Project Backend}`);
});
module.exports = server;