import { NextResponse } from "next/server"; import { SkillsService } from "@/services"; interface RouteParams { params: { categoryId: string; }; } export async function GET(request: Request, { params }: RouteParams) { try { const skills = await SkillsService.getSkillsByCategory(params.categoryId); return NextResponse.json(skills); } catch (error) { console.error("Error loading skills by category:", error); return NextResponse.json( { error: "Failed to load skills by category" }, { status: 500 } ); } } export async function POST(request: Request, { params }: RouteParams) { try { const skillData: { id: string; name: string; description: string; icon?: string; links: string[]; } = await request.json(); // Validate required fields if (!skillData.id || !skillData.name || !skillData.description) { return NextResponse.json( { error: "Missing required fields: id, name, description" }, { status: 400 } ); } await SkillsService.createSkill({ ...skillData, categoryId: params.categoryId, links: skillData.links || [], }); return NextResponse.json({ success: true }, { status: 201 }); } catch (error) { console.error("Error creating skill:", error); return NextResponse.json( { error: "Failed to create skill" }, { status: 500 } ); } }