first public source commit

This commit is contained in:
Ben Phelps 2022-08-24 10:44:35 +03:00
parent 1a4fbb9d42
commit 3914fee775
65 changed files with 4697 additions and 312 deletions

View file

@ -0,0 +1,22 @@
import { promises as fs } from "fs";
import path from "path";
import yaml from "js-yaml";
import checkAndCopyConfig from "utils/config";
export default async function handler(req, res) {
checkAndCopyConfig("widgets.yaml");
const widgetsYaml = path.join(process.cwd(), "config", "widgets.yaml");
const fileContents = await fs.readFile(widgetsYaml, "utf8");
const widgets = yaml.load(fileContents);
// map easy to write YAML objects into easy to consume JS arrays
const widgetsArray = widgets.map((group) => {
return {
type: Object.keys(group)[0],
options: { ...group[Object.keys(group)[0]] },
};
});
res.send(widgetsArray);
}