trying to add everything but models are messy with mongoose...just nonsense from higher perspective

This commit is contained in:
talksik
2022-04-01 12:28:09 -04:00
parent ce0fb7a885
commit 5f5d977012
12 changed files with 194 additions and 128 deletions
+17 -16
View File
@@ -3,8 +3,7 @@ import express, { Application, Request, Response } from "express";
import { NextFunction } from "express";
import SocketChannels from "@nirvana/core/sockets/channels";
import { UserService } from "./services/user.service";
import { UserStatus } from "@nirvana/core/models";
import { connectToDatabase } from "./services/database.service";
import { UserStatus } from "@nirvana/core/models/user.model";
import cors from "cors";
import getConversationRoutes from "./routes/conversation";
import getSearchRoutes from "./routes/search";
@@ -29,7 +28,6 @@ app.use("/api/conversations", getConversationRoutes());
const PORT = 5000;
var server = app.listen(PORT, () => console.log("express running"));
connectToDatabase();
// socket IO stuff
@@ -106,22 +104,25 @@ io.on("connection", function (socket: any) {
async (userGoogleId: string, newStatus: UserStatus) => {
console.log("new status for user");
const resultUpdate = await UserService.updateUserStatus(
userGoogleId,
newStatus
);
// todo persist status changes
// const resultUpdate = await UserService.updateUserStatus(
// userGoogleId,
// newStatus
// );
// tell all rooms that the user is part of
// that this user has updated their status
if (resultUpdate?.modifiedCount) {
socket.rooms.forEach((roomId: string) => {
io.in(roomId).emit(
SocketChannels.SEND_USER_STATUS_UPDATE,
userGoogleId,
newStatus
);
});
}
// if (resultUpdate?.modifiedCount) {
// }
socket.rooms.forEach((roomId: string) => {
io.in(roomId).emit(
SocketChannels.SEND_USER_STATUS_UPDATE,
userGoogleId,
newStatus
);
});
}
);