kaneo (minimalist kanban) fork to experiment adding a tangled integration github.com/usekaneo/kaneo
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 35 lines 878 B view raw
1import { eq } from "drizzle-orm"; 2import { HTTPException } from "hono/http-exception"; 3import db from "../../database"; 4import { commentTable } from "../../database/schema"; 5 6async function deleteComment(userId: string, id: string) { 7 const [existing] = await db 8 .select({ userId: commentTable.userId }) 9 .from(commentTable) 10 .where(eq(commentTable.id, id)) 11 .limit(1); 12 13 if (!existing) { 14 throw new HTTPException(404, { message: "Comment not found" }); 15 } 16 17 if (existing.userId !== userId) { 18 throw new HTTPException(403, { 19 message: "Only the author can delete this comment", 20 }); 21 } 22 23 const [deleted] = await db 24 .delete(commentTable) 25 .where(eq(commentTable.id, id)) 26 .returning(); 27 28 if (!deleted) { 29 throw new HTTPException(500, { message: "Failed to delete comment" }); 30 } 31 32 return deleted; 33} 34 35export default deleteComment;