Updated controller logic and greatly expanded on unit tests even though they timeout running through github actions

This commit is contained in:
Gregory Campbell
2021-11-25 16:07:40 -05:00
parent 25cc71f485
commit 4db3cdde29
2 changed files with 143 additions and 46 deletions
+6 -4
View File
@@ -54,10 +54,12 @@ const getOneMsg = (req, res) => {
//find the specific msg with that id
Msg.findOne({id:req.params.id}, (err, data) => {
if(err || !data) {
return res.status(400).json({message: "Message can't be found, it doesn't exist."});
}
else return res.status(200).json(data); //return the msg object if found
if(data) {
return res.status(200).json(data);
}else{
if(err) return res.status(404).json(`Something went wrong, please try again. ${err}`);
return res.status(400).json({message: "Message can't be found, it doesn't exist."});
}
});
};