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
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
/**
* referrals.ts — pure helpers for the Radar "referral links / free credits"
* feature (D28).
*
* DELIBERATELY DB-FREE: this file must be safe to import from a `"use
* client"` component (e.g. the providers dashboard) without pulling in
* `@/lib/db/*` (better-sqlite3 is Node-only and cannot be bundled into the
* browser). The DB-touching accessors (`getRadarReferrals`,
* `getDefaultReferralFor`) live in `./index.ts` and delegate the actual
* "which referral is the default for this provider" decision back to
* `findDefaultReferral` here, so the logic is defined exactly once and both
* the server accessor and the client UI use the same rule.
*/
import type { RadarReferral } from "./feedSchema";
/**
* Find the fixed, isDefault:true referral link for a provider.
*
* Only looks at `fixed` referrals by design — campaigns are never used as
* the "default" link on the provider name (they are temporary/opt-in extras
* surfaced separately on the Radar "free credits" tab).
*/
export function findDefaultReferral(
fixed: RadarReferral[],
provider: string,
): RadarReferral | null {
return fixed.find((r) => r.provider === provider && r.isDefault === true) ?? null;
}