aboutsummaryrefslogtreecommitdiff
path: root/src/util/config.ts
diff options
context:
space:
mode:
authorKevin J Hoerr <kjhoerr@protonmail.com>2021-09-12 10:08:51 -0400
committerKevin J Hoerr <kjhoerr@protonmail.com>2021-09-12 10:08:51 -0400
commitb659864f7a60e624f893c9ba7834e54af75d7a16 (patch)
tree03d65ba488f2f40ef8a1a0df166aa597475a063f /src/util/config.ts
parent521f426a1c658d5c48d272a28135ce77047f068f (diff)
downloadao-coverage-b659864f7a60e624f893c9ba7834e54af75d7a16.tar.gz
ao-coverage-b659864f7a60e624f893c9ba7834e54af75d7a16.tar.bz2
ao-coverage-b659864f7a60e624f893c9ba7834e54af75d7a16.zip
Refactor env config into Metadata
Diffstat (limited to 'src/util/config.ts')
-rw-r--r--src/util/config.ts9
1 files changed, 5 insertions, 4 deletions
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<void> => {
export const handleStartup = async (
mongoUri: string,
- hostDir: string,
- publicPath: string,
+ config: EnvConfig,
targetUrl: string
): Promise<MongoClient> => {
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);