35 lines
807 B
TypeScript
35 lines
807 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { prisma } from '@/lib/db';
|
|
|
|
export async function GET(
|
|
request: NextRequest,
|
|
{ params }: { params: Promise<{ slug: string }> }
|
|
) {
|
|
const { slug } = await params;
|
|
|
|
// Fetch article to get its ID
|
|
const article = await prisma.article.findUnique({
|
|
where: { slug },
|
|
select: { id: true },
|
|
});
|
|
|
|
if (!article) {
|
|
return NextResponse.json({ error: 'Article not found' }, { status: 404 });
|
|
}
|
|
|
|
// Fetch history entries
|
|
const history = await prisma.articleHistory.findMany({
|
|
where: { articleId: article.id },
|
|
orderBy: { createdAt: 'desc' },
|
|
select: {
|
|
id: true,
|
|
oldContent: true,
|
|
newContent: true,
|
|
reason: true,
|
|
createdAt: true,
|
|
},
|
|
});
|
|
|
|
return NextResponse.json(history);
|
|
}
|