adding in socket io in backend and server running with it and needs testing with the client side
This commit is contained in:
+11
-1
@@ -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();
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user