- Update API route handlers to use async params for Next.js 15 compatibility - Fix MUI DataGrid deprecated props (pageSize -> initialState.pagination) - Replace Material-UI Grid components with Box for better compatibility - Fix admin authentication system with proper request parameters - Update permission constants to match available AdminPermission enum values - Add missing properties to Page interface for type safety - Update .gitignore to exclude venv/, import logs, and large data directories - Optimize Next.js config to reduce memory usage during builds 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { prisma } from '@/lib/db';
|
|
|
|
export async function GET(
|
|
request: NextRequest,
|
|
{ params }: { params: Promise<{ slug: string }> }
|
|
) {
|
|
try {
|
|
const resolvedParams = await params;
|
|
const page = await prisma.page.findUnique({
|
|
where: {
|
|
slug: resolvedParams.slug,
|
|
status: 'PUBLISHED'
|
|
},
|
|
select: {
|
|
id: true,
|
|
title: true,
|
|
slug: true,
|
|
content: true,
|
|
contentType: true,
|
|
excerpt: true,
|
|
featuredImage: true,
|
|
seoTitle: true,
|
|
seoDescription: true,
|
|
publishedAt: true,
|
|
updatedAt: true
|
|
}
|
|
});
|
|
|
|
if (!page) {
|
|
return NextResponse.json(
|
|
{ success: false, error: 'Page not found' },
|
|
{ status: 404 }
|
|
);
|
|
}
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
data: page
|
|
});
|
|
} catch (error) {
|
|
console.error('Error fetching page by slug:', error);
|
|
return NextResponse.json(
|
|
{ success: false, error: 'Failed to fetch page' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
} |