← back to ClawCoder
src/app/api/generate/route.ts
24 lines
import { NextResponse } from 'next/server'
import { getProfile } from '@/lib/profiles/data'
import { generateBundle } from '@/lib/generator/bundle'
export async function POST(request: Request) {
try {
const { profileSlug, vars } = await request.json()
if (!profileSlug) {
return NextResponse.json({ error: 'profileSlug is required' }, { status: 400 })
}
const profile = getProfile(profileSlug)
if (!profile) {
return NextResponse.json({ error: `Profile '${profileSlug}' not found` }, { status: 404 })
}
const bundle = generateBundle(profile, vars || {})
return NextResponse.json(bundle)
} catch {
return NextResponse.json({ error: 'Invalid request body' }, { status: 400 })
}
}