Update Next.js configuration for S3 support and enhance admin dashboard functionality - Added S3 hostname to next.config.js for image uploads - Updated package.json and package-lock.json with AWS SDK dependencies - Improved admin layout with S3 status component and enhanced dashboard statistics loading logic - Refactored news loading in NewsBlock component to handle errors gracefully.
This commit is contained in:
36
app/api/health/route.ts
Normal file
36
app/api/health/route.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
// Проверяем подключение к базе данных
|
||||
await prisma.$connect();
|
||||
|
||||
// Проверяем, что можем выполнить запрос
|
||||
const newsCount = await prisma.news.count();
|
||||
const userCount = await prisma.user.count();
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
status: 'healthy',
|
||||
database: 'connected',
|
||||
data: {
|
||||
newsCount,
|
||||
userCount,
|
||||
timestamp: new Date().toISOString()
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Health check failed:', error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
status: 'unhealthy',
|
||||
database: 'disconnected',
|
||||
error: error instanceof Error ? error.message : 'Unknown error'
|
||||
}, { status: 500 });
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user