diff --git a/back-end/routes/addEventRoute.js b/back-end/routes/addEventRoute.js index 598651c..112684d 100644 --- a/back-end/routes/addEventRoute.js +++ b/back-end/routes/addEventRoute.js @@ -29,12 +29,8 @@ router.post( expenses: [], // initialize this as empty }); - console.log(newEvent); - const savedEvent = await newEvent.save(); - console.log("Event created:", savedEvent); - // Fetch and update each participant for (const userId of req.body.Members) { let user = await User.findById(userId); @@ -52,7 +48,6 @@ router.post( } await user.save(); - console.log(`Event added to user ${userId}`); } res.status(201).json({ diff --git a/back-end/routes/addExpensePayerRoute.js b/back-end/routes/addExpensePayerRoute.js index 9b7c535..50453a4 100644 --- a/back-end/routes/addExpensePayerRoute.js +++ b/back-end/routes/addExpensePayerRoute.js @@ -7,7 +7,6 @@ router.get("/EventMember/:eventId", async (req, res) => { try { //fetch all data const eventId = req.params.eventId; - console.log("eventId:", eventId); const eventMember = await Event.findById(eventId).populate("participants"); if (!eventMember) { return res diff --git a/back-end/routes/addExpenseRoute.js b/back-end/routes/addExpenseRoute.js index ab3a431..396592d 100644 --- a/back-end/routes/addExpenseRoute.js +++ b/back-end/routes/addExpenseRoute.js @@ -75,7 +75,6 @@ router.post( data: savedExpense, }); } catch (error) { - console.log(error); res.status(500).json({ status: "Error", message: error.message }); } } diff --git a/back-end/routes/expenseRoute.js b/back-end/routes/expenseRoute.js index 9ea75a1..8bdb547 100644 --- a/back-end/routes/expenseRoute.js +++ b/back-end/routes/expenseRoute.js @@ -8,7 +8,7 @@ router.get("/ExpenseDetail/:expenseId", async (req, res) => { const expenseSplit = await Expense.findById(expenseId) .populate("event") - .populate('paidBy', 'username') + .populate("paidBy", "username") .populate({ path: "splitDetails", populate: { @@ -28,7 +28,6 @@ router.get("/ExpenseDetail/:expenseId", async (req, res) => { return res.status(404).json({ message: "Expense not found" }); } // Return the user's events - console.log(expenseSplit); res.json(expenseSplit); } catch (error) { console.error("Error fetching expense details:", error); diff --git a/back-end/routes/loginRoute.js b/back-end/routes/loginRoute.js index 6a7ca89..e292fc0 100644 --- a/back-end/routes/loginRoute.js +++ b/back-end/routes/loginRoute.js @@ -6,13 +6,6 @@ router.post("/", async function (req, res, next) { const username = req.body.username; const password = req.body.password; - // if (!username || !password) { - // res - // .status(401) - // .json({ success: false, message: `No username or password supplied.` }); - // next(); - // } - if (!username || !password) { return res .status(401) diff --git a/back-end/routes/sendMessageRoute.js b/back-end/routes/sendMessageRoute.js index ee61a90..8356965 100644 --- a/back-end/routes/sendMessageRoute.js +++ b/back-end/routes/sendMessageRoute.js @@ -9,12 +9,8 @@ router.post("/", async (req, res) => { user: req.body.user, }); - console.log(newMessage); - const savedMessage = await newMessage.save(); - console.log("Event created:", savedMessage); - res.status(201).json({ status: "Success", message: "Message sent successfully!", diff --git a/back-end/routes/settlementRoute.js b/back-end/routes/settlementRoute.js index dfef9d4..9f972bc 100644 --- a/back-end/routes/settlementRoute.js +++ b/back-end/routes/settlementRoute.js @@ -1,7 +1,7 @@ const express = require("express"); const router = express.Router(); const { Settlement } = require("../models/Settlement.js"); -const { Expense } = require("../models/Expense.js") +const { Expense } = require("../models/Expense.js"); // Route to get settlements for a specific user as 'settleFrom' router.get("/from/:userId", async (req, res) => { @@ -9,7 +9,7 @@ router.get("/from/:userId", async (req, res) => { const userId = req.params.userId; const settlements = await Settlement.find({ - $or: [{ settleFrom: userId }, { settleTo: userId }] + $or: [{ settleFrom: userId }, { settleTo: userId }], }) .populate("settleTo") .populate("settleFrom") @@ -18,13 +18,12 @@ router.get("/from/:userId", async (req, res) => { model: "Expense", populate: { path: "paidBy", - model: "User" - } + model: "User", + }, }) .populate("event"); res.status(200).json(settlements); - console.log(settlements) } catch (error) { res .status(500) diff --git a/back-end/routes/userInfoPageRoute.js b/back-end/routes/userInfoPageRoute.js index f258f18..e748874 100644 --- a/back-end/routes/userInfoPageRoute.js +++ b/back-end/routes/userInfoPageRoute.js @@ -3,19 +3,19 @@ const router = express.Router(); const { User } = require("../models/User.js"); router.get("/:userId", async (req, res) => { - try { - const userId = req.params.userId; - const user = await User.findById(userId); - - if (!user) { - return res.status(404).json({ message: "User not found" }); - } - - res.json(user); - } catch (error) { - console.error("Error fetching user:", error); - res.status(500).json({ message: "Error fetching user data" }); + try { + const userId = req.params.userId; + const user = await User.findById(userId); + + if (!user) { + return res.status(404).json({ message: "User not found" }); } - }); + + res.json(user); + } catch (error) { + console.error("Error fetching user:", error); + res.status(500).json({ message: "Error fetching user data" }); + } +}); module.exports = router;