Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1000 B
Raw Blame
import { getSettings } from "@/lib/db/settings";

export type HomeSettings = { setupComplete?: unknown };

/**
 * Settings read for the Home Server Component (#14060).
 *
 * A corrupted `key_value` table makes getSettings() throw, which used to crash the
 * whole Home render with a 500. The degradation lives HERE, in the display-only
 * consumer — never inside getSettings() itself: auth/authz callers such as
 * isAuthRequired() rely on getSettings() rejecting so they fail CLOSED. Swallowing
 * the error at the DB layer would hand them password-less defaults and disable
 * auth for loopback requests.
 */
export async function loadHomeSettings(
  load: () => Promise<HomeSettings> = getSettings
): Promise<HomeSettings> {
  try {
    return await load();
  } catch (error: unknown) {
    const message = error instanceof Error ? error.message : String(error);
    console.warn(`[Home] Failed to load settings; rendering with defaults: ${message}`);
    return { setupComplete: false };
  }
}