Skip to content

Commit

Permalink
Add SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
Somnath-Chattaraj committed Oct 15, 2024
1 parent f20f170 commit b82ca1a
Show file tree
Hide file tree
Showing 17 changed files with 55,676 additions and 38 deletions.
Binary file added backend/dist/404.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion backend/dist/controllers/postController.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ const fetchSinglePost = (0, express_async_handler_1.default)((req, res) => __awa
},
User: {
select: {
user_id: true,
username: true,
pic: true,
},
Expand All @@ -224,6 +225,7 @@ const fetchSinglePost = (0, express_async_handler_1.default)((req, res) => __awa
user_id: true,
User: {
select: {
user_id: true,
username: true,
pic: true,
},
Expand Down Expand Up @@ -259,7 +261,19 @@ const deletePost = (0, express_async_handler_1.default)((req, res) => __awaiter(
if (post.User.user_id !== user_id) {
return res.status(401).json({ message: "Unauthorized" });
}
return res.status(200).json({ message: "Post deleted" });
// @ts-ignore
yield prisma_1.default.$transaction((prisma) => __awaiter(void 0, void 0, void 0, function* () {
yield prisma.comment.deleteMany({
where: { post_id: postId },
});
yield prisma.like.deleteMany({
where: { post_id: postId },
});
yield prisma.post.delete({
where: { post_id: postId },
});
}));
return res.status(200).json({ message: "Post and comments deleted" });
}));
exports.deletePost = deletePost;
// @ts-ignore
Expand Down Expand Up @@ -352,6 +366,9 @@ const deleteComment = (0, express_async_handler_1.default)((req, res) => __await
if (comment.User.user_id !== user_id) {
return res.status(401).json({ message: "Unauthorized" });
}
yield prisma_1.default.comment.delete({
where: { comment_id: commentId },
});
return res.status(200).json({ message: "Comment deleted" });
}));
exports.deleteComment = deleteComment;
Expand Down
Loading

0 comments on commit b82ca1a

Please sign in to comment.