From c582320cefafac79d49124bf8da6091c5a4c0240 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Tue, 6 Sep 2022 18:30:15 +0200 Subject: [PATCH] Created the env check util --- util/envCheck.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 util/envCheck.ts diff --git a/util/envCheck.ts b/util/envCheck.ts new file mode 100644 index 0000000..5557a9f --- /dev/null +++ b/util/envCheck.ts @@ -0,0 +1,14 @@ +/** The predefined environment values */ +const envValue: string[] = [ + "MONGOOSE_STRING" +] + +/** Checks if the provided value is registered in process.env */ +const isRegistered = (value: string) => process.env[value]; + +/** Validates the .env file */ +module.exports.validate = () => { + for (let value of envValue) { + if (!isRegistered(value)) throw new Error(`Please register the environment value '${value}' in your .env file`); + } +} \ No newline at end of file