import { NextResponse } from 'next/server'; import { getServerSession } from 'next-auth'; import { authOptions } from "@/app/api/auth/options"; import { createUserFolderStructure } from '@/lib/s3'; export async function GET(request: Request) { try { // Get session const session = await getServerSession(authOptions); if (!session?.user?.id) { return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); } const userId = session.user.id; console.log(`Manually creating all folders for user: ${userId}`); // Create the folder structure for the user const result = await createUserFolderStructure(userId); return NextResponse.json({ success: true, message: 'All folders created successfully', userId }); } catch (error) { console.error('Error creating folders:', error); return NextResponse.json({ error: 'Failed to create folders', message: error instanceof Error ? error.message : String(error) }, { status: 500 }); } }