adding boilerplate for database validations

This commit is contained in:
talksik
2022-06-08 08:16:27 -05:00
parent f0b76497c5
commit 4879d3fb80
2 changed files with 10 additions and 3 deletions
@@ -24,6 +24,12 @@ const usersCollection: mongoDB.Collection = db.collection('users');
const lineCollection: mongoDB.Collection = db.collection('lines');
const lineMembersCollection: mongoDB.Collection = db.collection('lineMembers');
// client.on('connection', () => {
// db.command({
// collMod: 'lines',
// });
// });
collections.users = usersCollection;
collections.lines = lineCollection;
collections.lineMembers = lineMembersCollection;
+4 -3
View File
@@ -79,11 +79,12 @@ export default function InitializeWs(io: any) {
/** CONNECT | User wants to subscribe to live emissions of a line */
socket.on(ServerRequestChannels.CONNECT_TO_LINE, (req: ConnectToLineRequest) => {
// add this user to the room
console.log(`${socket.id} user CONNECTED room for line ${Object.keys(socket.rooms)}`);
const roomName = `connectedLine:${req.lineId}`;
socket.join(roomName);
console.log(`${socket.id} user CONNECTED room for line ${Object.keys(socket.rooms)}`);
const clientUserIdsInRoom = [...(io.sockets.adapter.rooms.get(roomName) ?? [])].map(
(otherUserSocketId: string) => socketIdsToUserIds[otherUserSocketId],
);
@@ -96,11 +97,11 @@ export default function InitializeWs(io: any) {
/** TUNE | User tunes into the line either temporarily or toggled in */
socket.on(ServerRequestChannels.TUNE_INTO_LINE, async (req: TuneToLineRequest) => {
console.log(`${socket.id} user TUNED into room for line ${req.lineId}`);
const roomName = `tunedLine:${req.lineId}`;
socket.join(roomName);
console.log(`${socket.id} user TUNED into room for line ${req.lineId}`);
const clientUserIdsInRoom = [...(io.sockets.adapter.rooms.get(roomName) ?? [])].map(
(otherUserSocketId: string) => socketIdsToUserIds[otherUserSocketId],
);