// app/api/admin/meta/route.ts
import { NextResponse } from 'next/server';
import { prisma } from '@/lib/prisma';
import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/auth-options';

export async function GET() {
  // Basic protection: ensure signed-in user is admin. Modify as needed.
  // If you want stricter, get session from context or check roles.
  // Here we skip session check to let dev access; but production should check.
  try {
    const courses = await prisma.course.findMany({ orderBy: { title: 'asc' } });
    const playlists = await prisma.playlist.findMany({ orderBy: { title: 'asc' } });
    return NextResponse.json({ courses, playlists });
  } catch (err) {
    console.error(err);
    return NextResponse.json({ error: 'server' }, { status: 500 });
  }
}
