diff options
| author | Kevin J Hoerr <kjhoerr@protonmail.com> | 2021-09-20 19:43:18 +0000 |
|---|---|---|
| committer | Kevin J Hoerr <kjhoerr@protonmail.com> | 2021-09-20 19:43:18 +0000 |
| commit | f830bab4ec14f3fe814962a6a2dee180149c3a6a (patch) | |
| tree | 9a7c3138c0afd2ce5423002d6d8163bbf39ea318 /src/util/config.ts | |
| parent | 67c22d10e4583e29d33933e4b1b88f9d02f3da47 (diff) | |
| download | ao-coverage-f830bab4ec14f3fe814962a6a2dee180149c3a6a.tar.gz ao-coverage-f830bab4ec14f3fe814962a6a2dee180149c3a6a.tar.bz2 ao-coverage-f830bab4ec14f3fe814962a6a2dee180149c3a6a.zip | |
The Whole Barnshow Commit
- Use yarn-berry instead of npm, with Zero Install feature and goodies
- Add `initializeToken` to post unique token to logs on startup
- Package upgrades
- Fix index.html.template tests
I will never do this again
Diffstat (limited to 'src/util/config.ts')
| -rw-r--r-- | src/util/config.ts | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/util/config.ts b/src/util/config.ts index 3b09590..e83eab7 100644 --- a/src/util/config.ts +++ b/src/util/config.ts @@ -3,6 +3,7 @@ import { MongoClient, MongoError } from "mongodb"; import { Server } from "http"; import path from "path"; import fs from "fs"; +import { v4 as uuid } from "uuid"; import loggerConfig from "./logger"; import processTemplate, { Template } from "../templates"; @@ -10,6 +11,21 @@ import { EnvConfig } from "../metadata"; const logger = winston.createLogger(loggerConfig("ROOT")); +export const initializeToken = (): string => { + //TODO check for token in hostDir/persist created token in hostDir so it's not regenerated on startup + const newToken = uuid(); + + logger.warn( + "TOKEN variable not provided, using this value instead: %s", + newToken + ); + logger.warn( + "Use this provided token to push your coverage reports to the server." + ); + + return newToken; +}; + export const configOrError = (varName: string): string => { const value = process.env[varName]; if (value !== undefined) { @@ -58,9 +74,7 @@ export const handleStartup = async ( await Promise.reject("hostDir must be an absolute path"); } - const mongo = await MongoClient.connect(mongoUri, { - useUnifiedTopology: true - }).catch((err: MongoError) => + const mongo = await MongoClient.connect(mongoUri).catch((err: MongoError) => Promise.reject(err.message ?? "Unable to connect to database") ); |
