(req, res)
| 65 | } |
| 66 | |
| 67 | export const likePost = async (req, res) => { |
| 68 | const { id } = req.params; |
| 69 | |
| 70 | if (!mongoose.Types.ObjectId.isValid(id)) return res.status(404).send(`No post with id: ${id}`); |
| 71 | |
| 72 | const post = await PostMessage.findById(id); |
| 73 | |
| 74 | const updatedPost = await PostMessage.findByIdAndUpdate(id, { likeCount: post.likeCount + 1 }, { new: true }); |
| 75 | |
| 76 | res.json(updatedPost); |
| 77 | } |
| 78 | |
| 79 | |
| 80 | export default router; |
nothing calls this directly
no outgoing calls
no test coverage detected