From b659864f7a60e624f893c9ba7834e54af75d7a16 Mon Sep 17 00:00:00 2001 From: Kevin J Hoerr Date: Sun, 12 Sep 2021 10:08:51 -0400 Subject: Refactor env config into Metadata --- src/util/config.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/util/config.ts') diff --git a/src/util/config.ts b/src/util/config.ts index 3f14db1..a0de761 100644 --- a/src/util/config.ts +++ b/src/util/config.ts @@ -6,6 +6,7 @@ import fs from "fs"; import loggerConfig from "./logger"; import processTemplate, { Template } from "../templates"; +import { EnvConfig } from "../metadata"; const logger = winston.createLogger(loggerConfig("ROOT")); @@ -47,11 +48,11 @@ export const persistTemplate = async (input: Template): Promise => { export const handleStartup = async ( mongoUri: string, - hostDir: string, - publicPath: string, + config: EnvConfig, targetUrl: string ): Promise => { try { + const { hostDir, publicDir } = config; await fs.promises.access(hostDir, fs.constants.R_OK | fs.constants.W_OK); if (!path.isAbsolute(hostDir)) { await Promise.reject("hostDir must be an absolute path"); @@ -64,12 +65,12 @@ export const handleStartup = async ( ); await persistTemplate({ - inputFile: path.join(publicPath, "templates", "bash.template"), + inputFile: path.join(publicDir, "templates", "bash.template"), outputFile: path.join(hostDir, "bash"), context: { TARGET_URL: targetUrl } } as Template); await persistTemplate({ - inputFile: path.join(publicPath, "templates", "index.html.template"), + inputFile: path.join(publicDir, "templates", "index.html.template"), outputFile: path.join(hostDir, "index.html"), context: { TARGET_URL: targetUrl } } as Template); -- cgit