MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / writeCaddyfile

Function writeCaddyfile

self-hosting/quiz.ts:37–58  ·  view source on GitHub ↗
(domainName: string, basicAuthPassword: string)

Source from the content-addressed store, hash-verified

35}
36
37function writeCaddyfile(domainName: string, basicAuthPassword: string) {
38 const caddyfileTemplatePath = path.resolve(
39 __dirname,
40 'caddy',
41 'Caddyfile.template',
42 );
43 const caddyfilePath = path.resolve(__dirname, 'caddy', 'Caddyfile');
44 fs.writeFileSync(
45 caddyfilePath,
46 fs
47 .readFileSync(caddyfileTemplatePath, 'utf-8')
48 .replaceAll('$DOMAIN_NAME', domainName.replace(/https?:\/\//, ''))
49 .replaceAll(
50 '$BASIC_AUTH_PASSWORD',
51 bcrypt.hashSync(basicAuthPassword, 10),
52 )
53 .replaceAll(
54 '$SSL_CONFIG',
55 domainName.includes('localhost:443') ? '\n\ttls internal' : '',
56 ),
57 );
58}
59
60export interface DockerComposeFile {
61 version: string;

Callers 1

initiateOnboardingFunction · 0.85

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected