import fs from "fs";
import dir from "path";
import os from "os";

export function getSettingValue(key: any) {
  let value: any = {};

  try {
    const keyFilename = dir.join(os.tmpdir(), `whaticket_settings.json`);
    const jsonData = fs.readFileSync(keyFilename, "utf8");
    const settings = JSON.parse(jsonData);
    value = settings.find((s: any) => s.key === key);
  } catch (err) {
    console.error("Error reading or parsing data from file:", err);
  }

  return value;
}
