/**
 * Server-only Shopify environment helpers.
 * Never import this module from client components or shared code
 * that could be bundled into the browser.
 */

function requireEnv(name: "SHOPIFY_API_KEY" | "SHOPIFY_API_SECRET"): string {
  const value = process.env[name];
  if (!value) {
    throw new Error(`Missing required environment variable: ${name}`);
  }
  return value;
}

/** Public Client ID — safe to send to the browser (e.g. Polaris meta tag). */
export function getShopifyApiKey(): string {
  return requireEnv("SHOPIFY_API_KEY");
}

/** App secret — server-side only. Never return this from a loader/action to the client. */
export function getShopifyApiSecret(): string {
  return requireEnv("SHOPIFY_API_SECRET");
}
