diff --git a/util/envCheck.ts b/util/envCheck.ts index 5836997..c945351 100644 --- a/util/envCheck.ts +++ b/util/envCheck.ts @@ -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(); } \ No newline at end of file