diff --git a/SerpentRace_Backend/src/Api/index.ts b/SerpentRace_Backend/src/Api/index.ts index 34290b3a..5bcc6a6e 100644 --- a/SerpentRace_Backend/src/Api/index.ts +++ b/SerpentRace_Backend/src/Api/index.ts @@ -27,6 +27,36 @@ const isDevelopment = process.env.NODE_ENV === 'development'; const loggingService = LoggingService.getInstance(); +// Validate required environment variables in production +if (process.env.NODE_ENV === 'production') { + const requiredEnvVars = [ + 'JWT_SECRET', + 'DB_PASSWORD', + 'DB_HOST', + 'DB_NAME', + 'POSTGRES_PASSWORD' + ]; + + const missingVars = requiredEnvVars.filter(varName => !process.env[varName]); + + if (missingVars.length > 0) { + logError('[FATAL] Missing required environment variables in production:', missingVars.join(', ')); + logError('[FATAL] Please configure all required environment variables in .env.server'); + process.exit(1); + } + + // Check for placeholder values that haven't been changed + if (process.env.JWT_SECRET && process.env.JWT_SECRET.includes('CHANGE_THIS')) { + logError('[FATAL] JWT_SECRET still contains placeholder value. Please set a proper secret in .env.server'); + process.exit(1); + } + + if (process.env.POSTGRES_PASSWORD && process.env.POSTGRES_PASSWORD.includes('CHANGE_THIS')) { + logError('[FATAL] POSTGRES_PASSWORD still contains placeholder value. Please set a proper password in .env.server'); + process.exit(1); + } +} + logStartup('SerpentRace Backend starting up', { environment: process.env.NODE_ENV || 'development', port: PORT, diff --git a/SerpentRace_Backend/tsconfig.json b/SerpentRace_Backend/tsconfig.json index 3b8f8bca..e3af7671 100644 --- a/SerpentRace_Backend/tsconfig.json +++ b/SerpentRace_Backend/tsconfig.json @@ -12,7 +12,7 @@ /* Language and Environment */ "target": "ES2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - "lib": ["ES2020"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ // "jsx": "preserve", /* Specify what JSX code is generated. */ // "libReplacement": true, /* Enable lib replacement. */ "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */