/**
 * GET /api/docs/[...slug] — Read a specific doc by its slug path.
 * Example: GET /api/docs/docs/STRIPE_SETUP_GUIDE
 */

import { NextRequest, NextResponse } from 'next/server';
import { readDoc } from '@/lib/docs';

export async function GET(_req: NextRequest, { params }: { params: Promise<{ slug: string[] }> }) {
  const { slug } = await params;
  const slugPath = slug.join('/');
  const result = readDoc(slugPath);

  if (!result) {
    return NextResponse.json({ error: 'Document not found' }, { status: 404 });
  }

  return NextResponse.json(result);
}
