import { readdir, readFile } from "fs/promises"; interface enum_types { name: string, node: null | string, field_or_param: string, values: string[] }; interface nodes { [key: string]: { apis: Array<{ method: "GET" | "POST" | "DELETE", endpoint?: string, return: string, params: Array<{ name: string, required: boolean, type: string }>, name?: "#delete" | "#get" | "#update" }>, fields: Array<{ name: string, type: string }> } }; const apiSpecsPath = './api_specs/' export default async function () { const { enum_types, ...nodes } = await readdir(apiSpecsPath, { withFileTypes: true }).then(names => names.filter(r => r.isFile() && r.name.endsWith('.json')).map(r => r.name).map(async name => ([name.replace('.json', ''), await readFile(apiSpecsPath + name).then(json => JSON.parse(json.toString()))]))).then(async names => Object.fromEntries(await Promise.all(names))) return { nodes, enum_types } as { nodes: nodes, enum_types: enum_types[] } }