Created the env check util

This commit is contained in:
Mathias Wagner 2022-09-06 18:30:15 +02:00
parent 322b95e2c4
commit c582320cef
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

14
util/envCheck.ts Normal file
View File

@ -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`);
}
}