Skip to content

Commit

Permalink
Commented out console.log lines
Browse files Browse the repository at this point in the history
  • Loading branch information
chrsrns committed Oct 16, 2023
1 parent f05a24f commit 102a5e6
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 45 deletions.
7 changes: 2 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ const { PrismaClient } = require("@prisma/client");
const prisma = new PrismaClient();

const resetAll = async () => {
console.log("Resetting online status")
console.log(await prisma.user.updateMany({
await prisma.user.updateMany({
where: {
isOnline: true
},
data: {
isOnline: false
}
}))
})
}
resetAll()

Expand Down Expand Up @@ -74,7 +73,6 @@ app.post("/backend/fakestudentuser", async (req, res) => {
);
res.json(name);
} catch (error) {
console.error(error);
res.status(500).json({ error: "An error occurred!" });
}
})
Expand All @@ -88,7 +86,6 @@ app.post("/backend/fakestaffuser", async (req, res) => {
);
res.json(name);
} catch (error) {
console.error(error);
res.status(500).json({ error: "An error occurred!" });
}
})
Expand Down
18 changes: 9 additions & 9 deletions routes/admin.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ router.put("/pendinguser/:id", async (req, res) => {
res.status(200)
return next()
} catch (error) {
console.error(error);
// console.error(error);
res
.status(500)
.json({ error: "An error occurred while modifying the user" });
Expand Down Expand Up @@ -109,7 +109,7 @@ router.post("/user", async (req, res, next) => {
})
res.status(200)
} catch (err) {
console.error(err);
// console.error(err);
res.status(500).json({ error: "An error occurred when adding the user" });
}

Expand All @@ -135,7 +135,7 @@ router.put("/user/:id", async (req, res) => {
res.status(200)
return next()
} catch (error) {
console.error(error);
// console.error(error);
res
.status(500)
.json({ error: "An error occurred while modifying the user" });
Expand All @@ -155,9 +155,9 @@ router.delete("/user/:id", async (req, res) => {
return;
}
res.json(userToDelete);
console.log(req.body)
// console.log(req.body)
} catch (error) {
console.error(error);
// console.error(error);
res
.status(500)
.json({ error: "An error occurred while deleting the user" });
Expand Down Expand Up @@ -186,7 +186,7 @@ router.post("/announcement", async (req, res, next) => {
})
res.status(200)
} catch (err) {
console.error(err);
// console.error(err);
res.status(500).json({ error: "An error occurred when adding the announcement" });
}

Expand All @@ -210,7 +210,7 @@ router.put("/announcement/:id", async (req, res) => {
res.status(200)
return next()
} catch (error) {
console.error(error);
// console.error(error);
res
.status(500)
.json({ error: "An error occurred while modifying the announcement" });
Expand All @@ -230,9 +230,9 @@ router.delete("/announcement/:id", async (req, res) => {
return;
}
res.json(announcementToDelete);
console.log(req.body)
// console.log(req.body)
} catch (error) {
console.error(error);
// console.error(error);
res
.status(500)
.json({ error: "An error occurred while deleting the announcement" });
Expand Down
15 changes: 6 additions & 9 deletions routes/appointments.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ router.get("/schedules", async (req, res, next) => {
})
res.json(schedules)
} catch (err) {
console.error(err)
res.status(500).json({ msg: err.message });
}
})
Expand Down Expand Up @@ -257,7 +256,6 @@ router.get("/schedule/:id", async (req, res) => {
}
res.json(schedule);
} catch (error) {
console.error(error);
res
.status(500)
.json({ error: "An error occurred while fetching the schedule" });
Expand All @@ -280,14 +278,13 @@ router.put("/schedule/:id", async (req, res) => {
}

schedule.Users.forEach(element => {
console.log("Notifying user ", element.id)
socketIO.to(element.id).emit("schedule updated", {
schedTitle: schedule.title
})
});
res.json(schedule);
} catch (error) {
console.error(error);
// console.error(error);
res
.status(500)
.json({ error: "An error occurred while modifying the schedule" });
Expand All @@ -307,9 +304,9 @@ router.delete("/schedule/:id", async (req, res) => {
return;
}
res.json(schedule);
console.log(req.body)
// console.log(req.body)
} catch (error) {
console.error(error);
// console.error(error);
res
.status(500)
.json({ error: "An error occurred while deleting the schedule" });
Expand All @@ -330,7 +327,7 @@ router.post("/schedule", async (req, res, next) => {
})
res.json()
} catch (err) {
console.error(err);
// console.error(err);
res.status(500).json({ error: "An error occurred!" });
}
})
Expand Down Expand Up @@ -374,14 +371,14 @@ router.post("/message", async (req, res, next) => {
const token = authorizationHeader.replace('Bearer ', '');
messageData.userId = findUserIdByAccessToken(token)

console.log(messageData)
// console.log(messageData)
res.status(200).json({ msg: "Message sent" })
try {
const message = await prisma.message.create({
data: messageData
})
} catch (err) {
console.error(err);
// console.error(err);
res.status(500).json({ error: "An error occurred!" });
}
})
Expand Down
10 changes: 5 additions & 5 deletions routes/auth.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ router.post('/register', async (req, res, next) => {

res.status(200).json(user);
} catch (err) {
console.error(err)
// console.error(err)
// TODO Improve error handling
res.status(500).json({ msg: err.message });
}
Expand Down Expand Up @@ -193,10 +193,10 @@ router.get("/decodeoauth", async (req, res, next) => {
audience: process.env.GOOGLE_CLIENT_ID,
})

console.log("Decoded: ", decoded)
// console.log("Decoded: ", decoded)
res.json(decoded)
} catch (error) {
console.error(error);
// console.error(error);
res
.status(500)
.json({ error: "An error occurred." });
Expand All @@ -216,7 +216,7 @@ router.get("/emailfromgoogle", async (req, res, next) => {
const email = await decoded.getPayload().email
res.json(email)
} catch (error) {
console.error(error);
// console.error(error);
res
.status(500)
.json({ error: "An error occurred." });
Expand Down Expand Up @@ -279,7 +279,7 @@ router.post('/googlelogin', async (req, res, next) => {
type: existingUser.type
});
} catch (err) {
console.error(err)
// console.error(err)
res.status(500).json({ msg: err.message });
}
});
Expand Down
4 changes: 2 additions & 2 deletions routes/feedback.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ router.post("/add", async (req, res, next) => {

const token = authorizationheader.replace('Bearer ', '');
const userId = findUserIdByAccessToken(token)
console.log(userId)
// console.log(userId)

const data = req.body
data.userId = userId
Expand All @@ -23,7 +23,7 @@ router.post("/add", async (req, res, next) => {

res.json(feedback);
} catch (error) {
console.error(error);
// console.error(error);
res
.status(500)
.json({ error: "An error occurred while creating a medical record" });
Expand Down
6 changes: 3 additions & 3 deletions routes/medrecords.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ router.get("/records", async (req, res, next) => {
})
res.json(medRecordsToGet)
} catch (err) {
console.error(err);
// console.error(err);
res.status(500).json({ error: "an error occurred!" });
}
});
Expand All @@ -36,7 +36,7 @@ router.get("/users", async (req, res, next) => {
})
res.json(users)
} catch (err) {
console.error(err);
// console.error(err);
res.status(500).json({ error: "an error occurred!" });
}
});
Expand All @@ -54,7 +54,7 @@ router.post("/record", async (req, res, next) => {

res.json(record);
} catch (error) {
console.error(error);
// console.error(error);
res
.status(500)
.json({ error: "An error occurred while creating a medical record" });
Expand Down
4 changes: 2 additions & 2 deletions routes/notifications.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ router.get("/notifications", async (req, res, next) => {
})
res.json(notificationsToGet)
} catch (err) {
console.error(err);
// console.error(err);
res.status(500).json({ error: "An error occurred!" });
}
});
Expand Down Expand Up @@ -51,7 +51,7 @@ router.put("/removeFromUsersToNotify/:id", async (req, res, next) => {
}
res.json(notification);
} catch (error) {
console.error(error);
// console.error(error);
res
.status(500)
.json({ error: "An error occurred while removing from notification" });
Expand Down
4 changes: 2 additions & 2 deletions routes/notifications.services.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ const createNotification = async ({ title, message, users = [] }) => {
usersToNotify: usersToAdd
},
});
console.log(createNotification)
// console.log(createNotification)

return createNotification
} catch (err) {
console.error(err)
// console.error(err)
}
}

Expand Down
4 changes: 2 additions & 2 deletions routes/users.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ router.get("/announcements", async (req, res, next) => {
);
res.json(announcements);
} catch (err) {
console.error(err);
// console.error(err);
res
.status(500)
.json({ error: "An error occurred while fetching announcements" });
Expand Down Expand Up @@ -58,7 +58,7 @@ router.get("/onlineusers", async (req, res, next) => {
});
res.json(user);
} catch (err) {
console.error(err);
// console.error(err);
res
.status(500)
.json({ error: "An error occurred while fetching online users" });
Expand Down
2 changes: 1 addition & 1 deletion routes/users.services.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function findUserById(id) {

function createUser(user) {
user.login_password = bcrypt.hashSync(user.login_password, 12);
console.log(user)
// console.log(user)
return db.user.create({
data: user,
});
Expand Down
10 changes: 5 additions & 5 deletions socket/connection.socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class Connection {

socket.on('disconnect', () => this.disconnect());
socket.on('connect_error', (err) => {
console.log(`connect_error due to ${err.message}`);
// console.log(`connect_error due to ${err.message}`);
});
}

disconnect() {
console.log('🔥: A user disconnected');
// console.log('🔥: A user disconnected');

this.updatePeopleOnline(this.socket.userId, false)

Expand All @@ -40,7 +40,7 @@ class Connection {
}
this.io.emit("users", users);
} catch (error) {
console.error(error);
// console.error(error);
}
}
}
Expand All @@ -56,7 +56,7 @@ function connect(io) {

const payload = jwt.verify(refreshToken, process.env.JWT_REFRESH_SECRET);
const savedRefreshToken = await findRefreshTokenById(payload.jti);
console.log(savedRefreshToken)
// console.log(savedRefreshToken)

if (!savedRefreshToken || savedRefreshToken.revoked === true) {
return next(new Error('unauthorized session'));
Expand Down Expand Up @@ -85,7 +85,7 @@ function connect(io) {
next()
})
io.on('connect', (socket) => {
console.log(`⚡: ${socket.id} user just connected!`);
// console.log(`⚡: ${socket.id} user just connected!`);
new Connection(io, socket)
socket.join(socket.userId)

Expand Down

0 comments on commit 102a5e6

Please sign in to comment.