Created the env check util
This commit is contained in:
parent
322b95e2c4
commit
c582320cef
14
util/envCheck.ts
Normal file
14
util/envCheck.ts
Normal 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`);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user