NeahNew/app/api/nextcloud/init/route.ts
2025-05-05 13:04:01 +02:00

28 lines
1.0 KiB
TypeScript

import { NextResponse } from 'next/server';
import { getServerSession } from 'next-auth';
import { authOptions } from "@/app/api/auth/options";
// This file serves as an adapter to redirect requests from the old NextCloud
// init endpoint to the new MinIO S3 init endpoint
export async function POST(request: Request) {
try {
// Get session
const session = await getServerSession(authOptions);
if (!session?.user) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
// Forward to storage handler
try {
const { POST: storageInitHandler } = await import('@/app/api/storage/init/route');
return await storageInitHandler(request);
} catch (error) {
console.error('Error calling storage init handler:', error);
return NextResponse.json({ error: 'Failed to initialize storage' }, { status: 500 });
}
} catch (error) {
console.error('Error in NextCloud init adapter:', error);
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
}
}