import { NextResponse } from 'next/server'; import fs from 'fs'; import path from 'path'; const tftpDir = '/var/lib/tftpboot/'; export async function GET() { try { const files = fs.readdirSync(tftpDir).map((filename) => { const filepath = path.join(tftpDir, filename); const stats = fs.statSync(filepath); return { name: filename, size: stats.size, }; }); return NextResponse.json({ files }); } catch (error) { return NextResponse.json({ error: 'Failed to list files' }, { status: 500 }); } }