nexus-dashboard/app/api/vms/route.ts
2026-02-01 18:42:22 +00:00

19 lines
649 B
TypeScript

import { NextResponse } from 'next/server';
import { getVMList } from '@/lib/ssh';
export async function GET() {
try {
console.log('[API] Fetching VM list...');
const vms = await getVMList();
console.log('[API] VMs fetched successfully:', vms.length);
return NextResponse.json({ vms });
} catch (error) {
console.error('[API] Error fetching VMs:', error);
console.error('[API] Error stack:', error instanceof Error ? error.stack : 'No stack trace');
return NextResponse.json(
{ error: 'Failed to fetch VMs', details: error instanceof Error ? error.message : String(error) },
{ status: 500 }
);
}
}