/**
 * GET /api/applications/[id]/files
 *
 * Returns the full directory tree for an application's repository path.
 * Used by the IDE tab's file explorer.
 */
import { resolve } from '../../../../../lib/server-container.js';
export const dynamic = 'force-dynamic';
export async function GET(_request, { params }) {
    try {
        const { id } = await params;
        const useCase = resolve('ListApplicationFilesUseCase');
        const tree = await useCase.execute({ applicationId: id });
        return Response.json({ tree });
    }
    catch (error) {
        // eslint-disable-next-line no-console
        console.error('[GET /api/applications/:id/files]', error);
        const message = error instanceof Error ? error.message : String(error);
        const status = /not found/i.test(message) ? 404 : 500;
        return Response.json({ error: message }, { status });
    }
}
