63ef43ec-90ce-4fcf-82b4-abff91b2280a

This commit is contained in:
Z User committed 2026-10-27 01:02:02 +00:00
1 parent 8fa25577c0
commit c71c7e3094
12 files changed
+578 -9

No files matched your search

@@ -0,0 +1,44 @@
import { NextResponse } from 'next/server'
import { db } from '@/lib/db'
export const dynamic = 'force-dynamic'
// GET /api/aos/tasks/[id]/comments — list comments on a task
export async function GET(
_req: Request,
{ params }: { params: Promise<{ id: string }> }
) {
const { id } = await params
const comments = await db.taskComment.findMany({
where: { taskId: id },
orderBy: { createdAt: 'asc' },
})
return NextResponse.json({ comments })
}
// POST /api/aos/tasks/[id]/comments — add a comment
export async function POST(
req: Request,
{ params }: { params: Promise<{ id: string }> }
) {
const { id } = await params
const { body, author } = (await req.json()) as { body: string; author?: string }
if (!body?.trim()) return NextResponse.json({ error: 'body required' }, { status: 400 })
const comment = await db.taskComment.create({
data: { taskId: id, body: body.trim(), author: author ?? 'Max Brandt' },
})
await db.auditLog.create({
data: {
actor: author ?? 'max@nordlicht.digital',
action: 'task.comment:create',
entity: 'TaskComment',
entityId: comment.id,
after: JSON.stringify({ taskId: id, length: body.length }),
hash: 'sha256:' + Math.random().toString(36).slice(2),
},
})
return NextResponse.json({ comment })
}