MCPcopy Index your code
hub / github.com/TomDoesTech/REST-API-Tutorial / deletePostHandler

Function deletePostHandler

src/controller/post.controller.ts:49–66  ·  view source on GitHub ↗
(req: Request, res: Response)

Source from the content-addressed store, hash-verified

47}
48
49export 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}

Callers

nothing calls this directly

Calls 2

findPostFunction · 0.90
deletePostFunction · 0.90

Tested by

no test coverage detected