import assert from "assert";
import fs from "fs";

export const CONFIG = "./secrets/config.json"

const load_config = () => {
  try {
    return JSON.parse(fs.readFileSync(CONFIG));
  } catch(error) {
    console.error(error, `You have a problem with your ${CONFIG}.`);
    return undefined;
  }
}

export const secrets = load_config();
assert(secrets !== undefined, `Problem loading config file ${CONFIG}`);

// TODO: migrate away from these but for now need them to keep the old code working
export const paypal_private = secrets.paypal_private;
export const btcpay_private = secrets.btcpay_private;
export const stripe_private = secrets.stripe_private;

export const canary_payments = secrets.canary_payments;
export const base_host = secrets.base_host;
export const bull_config = secrets.bull_config;
export const config_canary = secrets.config_canary;
export const payments_allow_zero = secrets.payments_allow_zero;
export const session_store = secrets.session_store;
export const loader = secrets.loader;
export const auth = secrets.auth;
export const media_servers = secrets.media_servers;
export const discord = secrets.discord;
export const socket = secrets.socket;
export const sync = secrets.sync;

export default secrets;
