import { getBootstrapState } from "@/modules/core/server/auth";
import { jsonFailure, jsonSuccess } from "@/modules/core/server/api";
import { ensureSystemDefaults } from "@/modules/core/server/permissions";

export const dynamic = "force-dynamic";

export async function GET(): Promise<Response> {
  try {
    await ensureSystemDefaults();
    const state = await getBootstrapState();
    return jsonSuccess("Bootstrap state loaded", state);
  } catch (error) {
    const reason = error instanceof Error ? error.message : "系统初始化状态读取失败";
    return jsonFailure(reason, 503);
  }
}
