-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
38 lines (26 loc) · 1004 Bytes
/
config.py
File metadata and controls
38 lines (26 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
from pathlib import Path
from dotenv import load_dotenv
ROOT_DIR = Path(__file__).resolve().parent
load_dotenv(ROOT_DIR / ".env")
def require_env(name: str) -> str:
value = os.getenv(name)
if not value:
raise RuntimeError(f"Missing required environment variable: {name}")
return value
def get_base_url() -> str:
return os.getenv("BRIDGEXAPI_BASE_URL", "https://hi.bridgexapi.io").rstrip("/")
def get_timeout() -> int:
raw = os.getenv("BRIDGEXAPI_TIMEOUT", "30")
try:
return int(raw)
except ValueError as exc:
raise RuntimeError("BRIDGEXAPI_TIMEOUT must be an integer") from exc
def get_default_route() -> int:
raw = os.getenv("BRIDGEXAPI_ROUTE_ID", "2")
try:
return int(raw)
except ValueError as exc:
raise RuntimeError("BRIDGEXAPI_ROUTE_ID must be an integer") from exc
def get_default_caller_id() -> str:
return os.getenv("BRIDGEXAPI_CALLER_ID", "BRIDGEXAPI")