forked from JSE-ORG/trust-link-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv-validation.js
More file actions
28 lines (23 loc) · 968 Bytes
/
Copy pathenv-validation.js
File metadata and controls
28 lines (23 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// This is the checklist of required setup keys the website MUST have to run
const REQUIRED_VARIABLES = [
'NEXT_PUBLIC_API_URL',
'NEXT_PUBLIC_STELLAR_NETWORK'
];
function checkEnvironmentVariables() {
const missingVariables = [];
// Loop through our checklist and see if any are missing
for (const name of REQUIRED_VARIABLES) {
if (!process.env[name]) {
missingVariables.push(name);
}
}
// If we found missing variables, crash clearly with an error message!
if (missingVariables.length > 0) {
console.error('❌ CRITICAL ERROR: You are missing required setup variables!');
console.error(`Please open your .env file and add these missing keys:\n- ${missingVariables.join('\n- ')}`);
// This line intentionally stops the app right here
throw new Error(`Missing environment configuration: ${missingVariables.join(', ')}`);
}
}
// Run the check immediately
checkEnvironmentVariables();