Skip to content

Commit b547c66

Browse files
authored
modify filter env var and logging
1 parent 86356a2 commit b547c66

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

config/envVarCheck.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ config();
66
validateEnv();
77

88
export default function validateEnv() {
9-
console.log(process.env.DISCORD_APPLICATION_ID);
10-
envKeys.forEach((key) => {
11-
console.log(process.env[key]);
12-
if (!process.env[key]) {
13-
console.warn(`Environment variable ${key} is not set.`);
14-
}
15-
});
9+
const missingEnvVars = envKeys.filter((key) => !process.env[key]);
10+
11+
// Logging missing environment variables and exit if any are missing
12+
if (missingEnvVars.length > 0) {
13+
console.error(`Missing environment variables: ${missingEnvVars.join(', ')}`);
14+
process.exit(1); // Exit with code 1 if any required env var is missing
15+
} else {
16+
console.log('All required environment variables are set.');
17+
}
1618
}

src/constants/variables.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export const DISCORD_PROFILE_SERVICE_DEVELOPMENT_HELP_GROUP =
77
"1209237447083303014"; //Change this for your local environment
88

99
export const envKeys = [
10-
"CURRENT_ENVIRONMENT",
1110
"DISCORD_APPLICATION_ID",
1211
"DISCORD_GUILD_ID",
1312
"DISCORD_TOKEN",

0 commit comments

Comments
 (0)