Coverage for app/config/config.py: 88%

16 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2026-02-19 12:46 +0000

1from .logging import setup_logging 

2 

3setup_logging() 

4 

5import os 

6from loguru import logger 

7 

8def get_env_variable(var_name: str, default: str | None = None) -> str: 

9 """Get an environment variable or return a default value.""" 

10 value = os.environ.get(var_name) 

11 if value is None or value == "": 

12 if default is None: 

13 logger.error(f"Environment variable {var_name} is not set.") 

14 raise ValueError(f"Environment variable {var_name} is required but not set.") 

15 logger.warning(f"Environment variable {var_name} is not set, using default value: {default}") 

16 return default 

17 logger.debug(f"Environment variable {var_name} is set to: {value}") 

18 return value 

19 

20# Global environment variables for the Constellation backend 

21ALLOWED_ORIGINS = get_env_variable("ALLOWED_ORIGINS", "http://localhost:3000,http://localhost:8000,http://localhost:8001").split(",") # front + Neo4j + Postgres 

22 

23# Hostnames 

24POSTGRES_HOSTNAME = get_env_variable("POSTGRES_HOSTNAME", "http://api-postgres") 

25 

26# SSE configuration 

27# NONE