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