From 184432f642468ba996c9543bfc7d4ef34ef765fc Mon Sep 17 00:00:00 2001 From: Ruakij Date: Wed, 24 Nov 2021 01:03:40 +0100 Subject: [PATCH] Added helper for env-vars --- src/helper/env.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/helper/env.js diff --git a/src/helper/env.js b/src/helper/env.js new file mode 100644 index 0000000..08bff89 --- /dev/null +++ b/src/helper/env.js @@ -0,0 +1,13 @@ +function requireEnvVars(requiredEnv){ + // Ensure required ENV vars are set + let unsetEnv = requiredEnv.filter((env) => !(typeof process.env[env] !== 'undefined')); + + if (unsetEnv.length > 0) { + return "Required ENV variables are not set: [" + unsetEnv.join(', ') + "]"; + } +} + +// Specify exports +module.exports = { + requireEnvVars +}; \ No newline at end of file