allow weather apis to use hidden api keys

This commit is contained in:
Ben Phelps 2022-09-05 20:14:14 +03:00
parent 08afa0b747
commit 5a8defb478
6 changed files with 61 additions and 12 deletions

View file

@ -1,5 +1,8 @@
import { join } from "path";
import { existsSync, copyFile } from "fs";
import { promises as fs } from "fs";
import path from "path";
import yaml from "js-yaml";
export default function checkAndCopyConfig(config) {
const configYaml = join(process.cwd(), "config", config);
@ -14,3 +17,11 @@ export default function checkAndCopyConfig(config) {
});
}
}
export async function getSettings() {
checkAndCopyConfig("settings.yaml");
const settingsYaml = path.join(process.cwd(), "config", "settings.yaml");
const fileContents = await fs.readFile(settingsYaml, "utf8");
return yaml.load(fileContents);
}