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 }); +});