Skip to content

Commit

Permalink
fix returns
Browse files Browse the repository at this point in the history
  • Loading branch information
michelleli01 committed Nov 26, 2023
1 parent 1deccaa commit 1601fe9
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions server/src/review/review.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ router.post('/getReviewsByCourseId', async (req, res) => {
const crossListOR = getCrossListOR(course);
const reviews = await getReviewsByCourse(crossListOR);

res.status(200).json({
return res.status(200).json({
message: `Successfully retrieved reviews by course id: ${courseId}`,
data: reviews,
});
Expand All @@ -104,7 +104,7 @@ router.post('/insertUser', async (req, res) => {
const insertUserRequest = req.body as InsertUserRequest;
const result = await insertUserCallback(insertUserRequest);
if (result === 1) {
res.status(200).json({ message: 'User successfully added!' });
return res.status(200).json({ message: 'User successfully added!' });
}

res.status(500).json({
Expand All @@ -131,7 +131,7 @@ router.post('/insertReview', async (req, res) => {

const insertUser = await insertUserCallback({ googleObject: ticket });
if (insertUser === 0) {
res.status(500).json({
return res.status(500).json({
error: 'There was an error inserting the user into the database.',
});
}
Expand All @@ -140,7 +140,7 @@ router.post('/insertReview', async (req, res) => {

const related = await Reviews.find({ class: classId });
if (related.find((v) => v.text === review.text)) {
res.status(400).json({
return res.status(400).json({
message:
'Review is a duplicate of an already existing review for this class!',
});
Expand Down Expand Up @@ -176,15 +176,15 @@ router.post('/insertReview', async (req, res) => {
{ $set: { reviews: newReviews } },
).exec();

res
return res
.status(200)
.json({
message: `Successfully inserted review with id ${fullReview._id} into database`,
});
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
res.status(500).json({ error: 'Unexpected error when adding review' });
return res.status(500).json({ error: 'Unexpected error when adding review' });
}
} else {
// eslint-disable-next-line no-console
Expand Down Expand Up @@ -218,7 +218,7 @@ router.post("/updateLiked", async (req, res) => {
if (ticket.hd === 'cornell.edu') {
const insertUser = await insertUserCallback({ googleObject: ticket });
if (insertUser === 0) {
res.status(500).json({ error: "There was an error inserting new user." });
return res.status(500).json({ error: "There was an error inserting new user." });
}

const netId = ticket.email.replace('@cornell.edu', '');
Expand Down Expand Up @@ -265,7 +265,7 @@ router.post("/updateLiked", async (req, res) => {

review = await Reviews.findOne({ _id: id }).exec();

res.status(200).json({
return res.status(200).json({
message: `Successfully updated review with id ${id}`,
data: sanitizeReview(review),
});
Expand All @@ -291,14 +291,14 @@ router.post("/userHasLiked", async (req, res) => {
if (!ticket) res.status(400).json({ error: 'Missing verification ticket' });

if (ticket.hd !== 'cornell.edu') {
res.status(400).json({
return res.status(400).json({
error: 'Error: non-Cornell email attempted to insert review',
});
}

const insertUser = await insertUserCallback({ googleObject: ticket });
if (insertUser === 0) {
res.status(500).json({ error: "Error occurred while attempting to create new user." });
return res.status(500).json({ error: "Error occurred while attempting to create new user." });
}

const netId = ticket.email.replace('@cornell.edu', '');
Expand All @@ -309,7 +309,7 @@ router.post("/userHasLiked", async (req, res) => {
hasLiked = true;
}

res
return res
.status(200)
.json({
message: `Retrieved whether student with netId: ${netId} has liked review with id ${id}`,
Expand Down

0 comments on commit 1601fe9

Please sign in to comment.