class SiteConfig { constructor({ tangledUrl, knotDomain, ownerDid, repoName, branch, baseDir, notFoundFilepath, }) { if (tangledUrl) { if ([ownerDid, repoName].some((v) => !!v)) { throw new Error("Cannot use ownerDid and repoName with url"); } } this.tangledUrl = tangledUrl; this.ownerDid = ownerDid; this.repoName = repoName; this.knotDomain = knotDomain; this.branch = branch; this.baseDir = baseDir; this.notFoundFilepath = notFoundFilepath; } } export class Config { constructor({ site, sites, subdomainOffset, cache = false }) { if (site && sites) { throw new Error("Cannot use both site and sites in config"); } this.site = site ? new SiteConfig(site) : null; this.sites = sites ? sites.map((site) => new SiteConfig(site)) : null; this.subdomainOffset = subdomainOffset; this.cache = cache; } static async fromFile(filepath) { const fs = await import("fs"); const config = JSON.parse(fs.readFileSync(filepath, "utf8")); return new Config(config); } }