20 lines
475 B
TypeScript
20 lines
475 B
TypeScript
import type { Service } from "./types";
|
|
|
|
/**
|
|
assembles the contents for caddyfile
|
|
**/
|
|
export function formatcaddyfile(proxies: Service[]): string {
|
|
let output = "# generated by typescript\n\n";
|
|
|
|
const proxyconfig = proxies.map(proxy => {
|
|
const fullDomain = `${proxy.subdomain}.${proxy.host.baseDomain}`;
|
|
const destination = `${proxy.host.ip}:${proxy.port}`
|
|
|
|
return `${fullDomain} {
|
|
reverse_proxy ${destination}
|
|
}`
|
|
}).join('\n');
|
|
|
|
return output + proxyconfig
|
|
}
|