Added the google authentication check into the envCheck util
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
/** The predefined environment values */
|
||||
import * as fs from "fs";
|
||||
|
||||
const envValue: string[] = [
|
||||
"MONGOOSE_STRING", "API_PORT", "SHORTENER_PORT", "CDN_PORT", "AS_PORT"
|
||||
]
|
||||
@ -6,9 +8,19 @@ const envValue: string[] = [
|
||||
/** Checks if the provided value is registered in process.env */
|
||||
const isRegistered = (value: string) => process.env[value];
|
||||
|
||||
/** Checks if the gbucket.json file exists */
|
||||
const checkGoogleAuthentication = () => {
|
||||
if (!fs.existsSync(process.cwd() + "/gbucket.json")) {
|
||||
console.warn("[ContentDelivery] Could not find gbucket.json. Content delivery disabled.");
|
||||
process.env.DISABLE_CONTENT_DELIVERY = "true"
|
||||
}
|
||||
}
|
||||
|
||||
/** 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`);
|
||||
}
|
||||
|
||||
checkGoogleAuthentication();
|
||||
}
|
Reference in New Issue
Block a user