diff --git a/server/src/auth/auth.router.ts b/server/src/auth/auth.router.ts index ec4ecaf51..426c0d90c 100644 --- a/server/src/auth/auth.router.ts +++ b/server/src/auth/auth.router.ts @@ -13,7 +13,7 @@ router.post('/isAdmin', async (req, res) => { const verify = await verifyAdminToken(adminRequest.token); if (verify === false) { - res.status(400).json({ error: `Unable to verify token: ${adminRequest.token} as an admin.` }); + return res.status(400).json({ error: `Unable to verify token: ${adminRequest.token} as an admin.` }); } res.status(200).json({ message: `Token: ${adminRequest.token} was successfully verified as an admin user.` }); diff --git a/server/src/profile/profile.router.ts b/server/src/profile/profile.router.ts index 909b89b95..20b754fcf 100644 --- a/server/src/profile/profile.router.ts +++ b/server/src/profile/profile.router.ts @@ -12,7 +12,7 @@ router.post('/getStudentEmailByToken', async (req, res) => { const email = await getUserEmail(token); if (!email) { - res.status(400).json({ message: `Email not found: ${email}` }); + return res.status(400).json({ message: `Email not found: ${email}` }); } res.status(200).json({ message: email }); @@ -33,7 +33,7 @@ router.post('/countReviewsByStudentId', async (req, res) => { try { const studentDoc = await getUserByNetId(netId); if (studentDoc === null) { - res.status(404).json({ + return res.status(404).json({ message: `Unable to find student with netId: ${netId}`, }); } @@ -58,7 +58,7 @@ router.post('/getTotalLikesByStudentId', async (req, res) => { try { const studentDoc = await getUserByNetId(netId); if (studentDoc === null) { - res.status(404).json({ + return res.status(404).json({ message: `Unable to find student with netId: ${netId}`, }); } @@ -94,7 +94,7 @@ router.post('/getReviewsbyStudentId', async (req, res) => { try { const studentDoc = await getUserByNetId(netId); if (studentDoc === null) { - res.status(404).json({ + return res.status(404).json({ message: `Unable to find student with netId: ${netId}`, }); } diff --git a/server/src/review/review.router.ts b/server/src/review/review.router.ts index 951092962..2cf24c27c 100644 --- a/server/src/review/review.router.ts +++ b/server/src/review/review.router.ts @@ -34,7 +34,7 @@ router.post('/getCourseById', async (req, res) => { const { courseId } = req.body as CourseIdQuery; try { const course = await getCourseByIdCallback(courseId); - res.status(200).json({ + return res.status(200).json({ message: `Successfully retrieved course by id ${courseId}`, data: course, }); @@ -53,7 +53,7 @@ router.post('/getCourseByInfo', async (req, res) => { const { number, subject } = req.body as ClassByInfoQuery; try { const course = await getClassByInfo(subject, number); - res.status(200).json({ + return res.status(200).json({ message: `Successfully retrieved course by info number: ${number} and subject: ${subject}`, data: course, }); @@ -62,7 +62,7 @@ router.post('/getCourseByInfo', async (req, res) => { console.log("Error: at 'getCourseByInfo' endpoint"); // eslint-disable-next-line no-console console.log(error); - res.status(500).json({ error: 'Internal Server Error' }); + return res.status(500).json({ error: 'Internal Server Error' }); } });