"feat: Update project structure documentation and add health route"

This commit is contained in:
2025-05-23 08:34:22 +02:00
parent 359cb4a219
commit 57d4d9c4e4
4 changed files with 90 additions and 101 deletions

View File

@@ -0,0 +1,49 @@
import { NextRequest, NextResponse } from 'next/server';
/**
* Health Check Endpoint für Frontend-Server
* GET /health
*/
export async function GET(request: NextRequest) {
try {
// Prüfe Backend-Verbindung
const backendUrl = process.env.BACKEND_API_URL || 'http://localhost:5000';
let backendStatus = 'unknown';
try {
// AbortController für Timeout verwenden
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 5000);
const backendResponse = await fetch(`${backendUrl}/health`, {
method: 'GET',
signal: controller.signal,
});
clearTimeout(timeoutId);
backendStatus = backendResponse.ok ? 'connected' : 'error';
} catch {
backendStatus = 'disconnected';
}
return NextResponse.json({
status: 'healthy',
service: 'myp-frontend',
timestamp: new Date().toISOString(),
version: '1.0.0',
backend: {
url: backendUrl,
status: backendStatus
},
environment: process.env.NODE_ENV || 'development'
}, { status: 200 });
} catch (error) {
return NextResponse.json({
status: 'unhealthy',
service: 'myp-frontend',
timestamp: new Date().toISOString(),
error: error instanceof Error ? error.message : 'Unknown error'
}, { status: 503 });
}
}