2025-12-08 16:31:30 +03:00

30 lines
930 B
TypeScript

import { NextRequest, NextResponse } from 'next/server'
import { redis } from '@/lib/redis'
export async function PUT(req: NextRequest, { params }: { params: { id: string } }) {
try {
const { id: commentId } = params
const { text } = await req.json()
await redis.set(`comment:${commentId}:text`, text)
return NextResponse.json({ success: true })
} catch (error) {
console.error('Comment edit error:', error)
return NextResponse.json({ error: 'Failed to edit comment' }, { status: 500 })
}
}
export async function DELETE(req: NextRequest, { params }: { params: { id: string } }) {
try {
const { id: commentId } = params
await redis.set(`comment:${commentId}:deleted`, 'true')
return NextResponse.json({ success: true })
} catch (error) {
console.error('Comment delete error:', error)
return NextResponse.json({ error: 'Failed to delete comment' }, { status: 500 })
}
}