32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { NextResponse } from 'next/server';
|
|
import { getServerSession } from 'next-auth';
|
|
import { authOptions } from '@/app/api/auth/[...nextauth]/route';
|
|
|
|
// This file serves as an adapter to redirect requests from the old NextCloud
|
|
// status endpoint to the new MinIO S3 status endpoint
|
|
|
|
export async function GET(request: Request) {
|
|
try {
|
|
// Get session
|
|
const session = await getServerSession(authOptions);
|
|
if (!session?.user) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
}
|
|
|
|
// Instead of making an HTTP request, directly call the handler function
|
|
// for the storage status endpoint
|
|
try {
|
|
const { GET: storageStatusHandler } = await import('@/app/api/storage/status/route');
|
|
const storageResponse = await storageStatusHandler();
|
|
|
|
// Return the response
|
|
return storageResponse;
|
|
} catch (error) {
|
|
console.error('Error calling storage status handler:', error);
|
|
return NextResponse.json({ error: 'Failed to get storage status' }, { status: 500 });
|
|
}
|
|
} catch (error) {
|
|
console.error('Error in NextCloud status adapter:', error);
|
|
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
|
}
|
|
} |