diff --git a/week-12/12.1 Relations/solution/src/config.js b/week-12/12.1 Relations/solution/src/config.js index 9a8a435ece..baadd4bcea 100644 --- a/week-12/12.1 Relations/solution/src/config.js +++ b/week-12/12.1 Relations/solution/src/config.js @@ -1,6 +1,17 @@ -module.exports = { +const dotenv = require('dotenv'); +dotenv.config(); // Load environment variables from a .env file if available + +const config = { + env: process.env.NODE_ENV || 'development', port: process.env.PORT || 3000, db: { - url: process.env.DATABASE_URL, + url: process.env.DATABASE_URL || 'postgres://localhost:5432/defaultdb', }, -}; \ No newline at end of file +}; + +// Error handling for missing critical environment variables +if (!process.env.DATABASE_URL) { + console.warn('Warning: DATABASE_URL is not set, using default local database'); +} + +module.exports = config;