import { NextRequest, NextResponse } from 'next/server';
import { validateLicenseAction } from '@/lib/setup/wizard-actions';

export async function POST(request: NextRequest) {
  try {
    const { licenseKey } = await request.json();
    if (!licenseKey || typeof licenseKey !== 'string') {
      return NextResponse.json({ valid: false, error: 'License key is required' }, { status: 400 });
    }
    const result = await validateLicenseAction(licenseKey);
    return NextResponse.json(result);
  } catch {
    return NextResponse.json({ valid: false, error: 'Validation failed' }, { status: 500 });
  }
}
