21 lines
485 B
JavaScript
21 lines
485 B
JavaScript
/**
|
|
* @module Checks for required environment variables and terminates the process if they are missing.
|
|
*/
|
|
const dotenvVariables = [
|
|
'NODE_ENV',
|
|
'PORT',
|
|
'SERVICE_NAME'
|
|
];
|
|
const missingDotenvVariables = [];
|
|
|
|
dotenvVariables.forEach(variable => {
|
|
if (!process.env[variable]) {
|
|
missingDotenvVariables.push(`${variable}`);
|
|
}
|
|
});
|
|
|
|
if (missingDotenvVariables.length) {
|
|
console.error(`Following dotenv variables are missing: ${missingDotenvVariables}`);
|
|
process.exit(-1);
|
|
}
|