@@ -11,13 +11,21 @@ class Config {
1111 private constructor ( ) {
1212 // Ensure that the token is available in the environment
1313 const token = process . env . TELEGRAM_BOT_TOKEN ;
14- const web_hook = process . env . WEB_HOOK ! ;
14+ const web_hook = process . env . WEB_HOOK ;
15+ const port = process . env . PORT ;
16+ const nodeEnv = process . env . NODE_ENV || 'development' ;
17+ if ( ! token ) {
18+ throw new Error ( 'Telegram bot token is missing. Please set TELEGRAM_BOT_TOKEN in the environment.' ) ;
19+ }
20+ if ( ! web_hook ) {
21+ throw new Error ( 'Web hook URL is missing. Please set WEB_HOOK in the environment.' ) ;
22+ }
23+
1524 if ( ! token ) {
1625 throw new Error ( 'Telegram bot token is missing. Please set TELEGRAM_BOT_TOKEN in the environment.' ) ;
1726 }
18- const port = process . env . PORT ! ;
1927 // Set the environment, defaulting to development if not set
20- const environment : 'development' | 'production' = process . env . NODE_ENV === 'production' ? 'production' : 'development' ;
28+ const environment : 'development' | 'production' = nodeEnv === 'production' ? 'production' : 'development' ;
2129
2230 // Database configuration with environment variables
2331 const dbUser = process . env . DB_USER ! ;
@@ -26,6 +34,8 @@ class Config {
2634 const dbPassword = process . env . DB_PASSWORD ! ;
2735 const dbPort = parseInt ( process . env . DB_PORT ! , 10 ) ;
2836 const dbUrl = environment === 'production' ? process . env . DATABASE_URL ! : process . env . DB_URL ! ;
37+
38+ // Initialize the config properties
2939 this . token = token ;
3040 this . environment = environment ;
3141 this . port = Number ( port ) ;
0 commit comments