Files
media-map/backend/app/core/config.py
Danilo Reyes 98622c4119 Add host configuration for backend server and update documentation
- Introduced a new `host` option in `flake.nix` to specify the server's bind address, defaulting to `0.0.0.0`.
- Updated `run.sh` to use the `HOST` environment variable for server binding.
- Modified `config.py` to read the `HOST` from environment variables, defaulting to `0.0.0.0`.
- Enhanced `README.md` with instructions for setting up the `HOST` variable and clarified access details for development and production modes.
- Adjusted `vite.config.ts` to allow frontend access from other computers by default.
2025-12-28 21:20:21 -06:00

44 lines
1.3 KiB
Python

"""Application configuration"""
from pydantic_settings import BaseSettings
from typing import Optional
import os
class Settings(BaseSettings):
"""Application settings"""
# Server
port: int = int(os.getenv("PORT", "8080"))
host: str = os.getenv("HOST", "0.0.0.0") # Default to all interfaces
# Database
postgres_socket_path: str = os.getenv("POSTGRES_SOCKET_PATH", "/run/postgresql")
postgres_db: str = os.getenv("POSTGRES_DB", "jawz")
postgres_user: str = os.getenv("POSTGRES_USER", os.getenv("USER", "jawz"))
# *arr API keys
sonarr_api_key: str = os.getenv("SONARR_API_KEY", "")
radarr_api_key: str = os.getenv("RADARR_API_KEY", "")
lidarr_api_key: str = os.getenv("LIDARR_API_KEY", "")
# *arr base URLs
sonarr_url: str = "http://127.0.0.1:8989"
radarr_url: str = "http://127.0.0.1:7878"
lidarr_url: str = "http://127.0.0.1:8686"
# Admin
admin_token: Optional[str] = os.getenv("MOVIEMAP_ADMIN_TOKEN")
@property
def database_url(self) -> str:
"""Build PostgreSQL connection string using Unix socket"""
return f"postgresql://{self.postgres_user}@/{self.postgres_db}?host={self.postgres_socket_path}"
class Config:
env_file = ".env"
case_sensitive = False
settings = Settings()