(req: Request, res: Response)
| 47 | } |
| 48 | |
| 49 | export async function deletePostHandler(req: Request, res: Response) { |
| 50 | const userId = get(req, "user._id"); |
| 51 | const postId = get(req, "params.postId"); |
| 52 | |
| 53 | const post = await findPost({ postId }); |
| 54 | |
| 55 | if (!post) { |
| 56 | return res.sendStatus(404); |
| 57 | } |
| 58 | |
| 59 | if (String(post.user) !== String(userId)) { |
| 60 | return res.sendStatus(401); |
| 61 | } |
| 62 | |
| 63 | await deletePost({ postId }); |
| 64 | |
| 65 | return res.sendStatus(200); |
| 66 | } |
nothing calls this directly
no test coverage detected