From 34cacdd43b4c92d90c114341c3078984982b1e1c Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Sat, 18 Apr 2026 15:57:57 +0800 Subject: [PATCH] feat(api): soft-delete comment from me scope Made-with: Cursor --- server/api/me/posts/[postId]/comments/[commentId].delete.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 server/api/me/posts/[postId]/comments/[commentId].delete.ts diff --git a/server/api/me/posts/[postId]/comments/[commentId].delete.ts b/server/api/me/posts/[postId]/comments/[commentId].delete.ts new file mode 100644 index 0000000..f0b5574 --- /dev/null +++ b/server/api/me/posts/[postId]/comments/[commentId].delete.ts @@ -0,0 +1,12 @@ +import { softDeleteComment } from "#server/service/post-comments"; + +export default defineWrappedResponseHandler(async (event) => { + const user = await event.context.auth.requireUser(); + const postId = Number(event.context.params?.postId); + const commentId = Number(event.context.params?.commentId); + if (!Number.isInteger(postId) || !Number.isInteger(commentId)) { + throw createError({ statusCode: 400, statusMessage: "无效请求" }); + } + await softDeleteComment({ postId, commentId, actorUserId: user.id }); + return R.success({ ok: true }); +});