- Created setup-directus-collections.js to automate the creation of tech stack collections, fields, and relations in Directus. - Created setup-directus-hobbies.js for setting up hobbies collection with translations. - Created setup-directus-projects.js for establishing projects collection with comprehensive fields and translations. - Added setup-tech-stack-directus.js to populate tech_stack_items with predefined data.
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
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 }
|
|
);
|
|
}
|
|
}
|