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

25 statements  

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

1import os 

2from loguru import logger 

3 

4from .logging import setup_logging 

5 

6setup_logging() 

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 

21TARGET = get_env_variable("TARGET", "dev") # prod / dev 

22ALLOWED_ORIGINS = get_env_variable("ALLOWED_ORIGINS", "http://localhost:3000,http://localhost:8003").split(",") # front + CRDT 

23 

24# Hostnames 

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

26SSE_HOSTNAME = get_env_variable("SSE_HOSTNAME", "http://sse-server") 

27 

28# Neo4j configuration 

29NEO4J_HOST = get_env_variable("NEO4J_HOST", "neo4j") 

30NEO4J_PORT = get_env_variable("NEO4J_PORT", "7687") 

31NEO4J_USER = get_env_variable("NEO4J_USER", "neo4j") 

32NEO4J_PASSWORD = get_env_variable("NEO4J_PASSWORD", "12345678") 

33 

34# Internal Constants 

35RESERVED_NODE_ATTRIBUTE_NAMES = [ 

36 "constellation_uuid", 

37 "node_uuid", 

38 "created_at", 

39 "updated_at", 

40 "word_count", 

41 "label_count", 

42 "link_count", 

43] 

44 

45RESERVED_NODE_LABEL_NAMES = [ 

46 "__sys__", 

47] 

48 

49RESERVED_LINK_ATTRIBUTE_NAMES = [ 

50 "constellation_uuid", 

51 "link_uuid", 

52 "created_at", 

53 "updated_at", 

54 "word_count", 

55]