adding in socket io in backend and server running with it and needs testing with the client side

This commit is contained in:
talksik
2022-03-21 10:54:56 -04:00
parent dff7d617f4
commit 5e3b788565
3 changed files with 177 additions and 5 deletions
+11 -1
View File
@@ -7,6 +7,7 @@ import getContactsRoutes from "./routes/contacts";
import getConversationRoutes from "./routes/conversation";
import getSearchRoutes from "./routes/search";
import getUserRoutes from "./routes/user";
import http from "http";
const app = express();
@@ -26,6 +27,15 @@ app.use("/api/search", getSearchRoutes());
app.use("/api/conversations", getConversationRoutes());
app.use("/api/contacts", getContactsRoutes());
app.listen(5000, () => console.log("Example app is listening on port 5000."));
const server = new http.Server(app);
server.listen(5000, () =>
console.log("Example app is listening on port 5000.")
);
const io = require("socket.io")(server);
io.on("connection", function (socket: any) {
console.log("a user connected");
});
connectToDatabase();
+2 -1
View File
@@ -9,7 +9,8 @@
"cors": "^2.8.5",
"express": "^4.17.3",
"google-auth-library": "^7.14.0",
"mongodb": "^4.4.1"
"mongodb": "^4.4.1",
"socket.io": "^4.4.1"
},
"scripts": {
"dev": "NODE_ENV=development && nodemon",