(req: Request, res: Response)
| 17 | } |
| 18 | |
| 19 | export async function updatePostHandler(req: Request, res: Response) { |
| 20 | const userId = get(req, "user._id"); |
| 21 | const postId = get(req, "params.postId"); |
| 22 | const update = req.body; |
| 23 | |
| 24 | const post = await findPost({ postId }); |
| 25 | |
| 26 | if (!post) { |
| 27 | return res.sendStatus(404); |
| 28 | } |
| 29 | |
| 30 | if (String(post.user) !== userId) { |
| 31 | return res.sendStatus(401); |
| 32 | } |
| 33 | |
| 34 | const updatedPost = await findAndUpdate({ postId }, update, { new: true }); |
| 35 | |
| 36 | return res.send(updatedPost); |
| 37 | } |
| 38 | export async function getPostHandler(req: Request, res: Response) { |
| 39 | const postId = get(req, "params.postId"); |
| 40 | const post = await findPost({ postId }); |
nothing calls this directly
no test coverage detected