import { NextResponse } from 'next/server';
import { sourceRegistry } from '@/lib/sources/registry';

export async function GET() {
  try {
    const allSources = sourceRegistry.getAllSources();
    const availability = await Promise.all(allSources.map(async s => ({
      id: s.id,
      name: s.name,
      category: s.category,
      available: await s.isAvailable(),
      description: s.description
    })));

    return NextResponse.json({
      sources: availability,
      timestamp: new Date().toISOString()
    });
  } catch (error: any) {
    return NextResponse.json(
      { error: 'Failed to fetch node diagnostics' },
      { status: 500 }
    );
  }
}
