import { NextRequest, NextResponse } from 'next/server'; import { getTechStack } from '@/lib/directus'; export const runtime = 'nodejs'; export const dynamic = 'force-dynamic'; /** * GET /api/tech-stack * * Loads Tech Stack from Directus with fallback to static data * * Query params: * - locale: en or de (default: en) */ export async function GET(request: NextRequest) { try { const { searchParams } = new URL(request.url); const locale = searchParams.get('locale') || 'en'; // Try to load from Directus const techStack = await getTechStack(locale); if (techStack && techStack.length > 0) { return NextResponse.json({ techStack, source: 'directus' }); } // Fallback: return empty (component will use hardcoded fallback) return NextResponse.json({ techStack: null, source: 'fallback' }); } catch (error) { console.error('Error loading tech stack:', error); return NextResponse.json( { techStack: null, error: 'Failed to load tech stack', source: 'error' }, { status: 500 } ); } }