import { NextResponse } from "next/server";
import { authErrorResponse } from "@/lib/auth/api";
import { getWorkspaceCapabilities } from "@/lib/capabilities";

export async function GET() {
  try {
    const capabilities = await getWorkspaceCapabilities();
    return NextResponse.json({ capabilities });
  } catch (error) {
    const authRes = authErrorResponse(error);
    if (authRes) return authRes;
    const message = error instanceof Error ? error.message : "讀取功能狀態失敗";
    return NextResponse.json({ error: message }, { status: 500 });
  }
}