app backend prima
This commit is contained in:
44
app/core/config.py
Normal file
44
app/core/config.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
from pathlib import Path
|
||||
|
||||
# Determina il percorso del file .env (nella root del progetto)
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
||||
ENV_FILE = BASE_DIR / ".env"
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Configurazione applicazione caricata da variabili d'ambiente"""
|
||||
|
||||
# Database
|
||||
DATABASE_URL: str = "postgresql://user:password@localhost:5432/terrain_monitor"
|
||||
|
||||
# JWT
|
||||
SECRET_KEY: str
|
||||
ALGORITHM: str = "HS256"
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
|
||||
|
||||
# MQTT
|
||||
MQTT_BROKER_HOST: str = "localhost"
|
||||
MQTT_BROKER_PORT: int = 1883
|
||||
# Topic pattern: terrain/{cliente_id}/{sito_id}/alarms
|
||||
# Wildcards: + (single level), # (multi level)
|
||||
MQTT_TOPIC_ALARMS: str = "terrain/+/+/alarms"
|
||||
MQTT_TOPIC_TELEMETRY: str = "terrain/+/+/telemetry" # Dati sensori periodici
|
||||
MQTT_TOPIC_STATUS: str = "terrain/+/+/status" # Stato sensori/gateway
|
||||
MQTT_USERNAME: str = ""
|
||||
MQTT_PASSWORD: str = ""
|
||||
|
||||
# Firebase
|
||||
FIREBASE_CREDENTIALS_PATH: str = "./firebase-credentials.json"
|
||||
|
||||
# Application
|
||||
DEBUG: bool = False
|
||||
APP_NAME: str = "Terrain Monitor API"
|
||||
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=str(ENV_FILE),
|
||||
env_file_encoding='utf-8'
|
||||
)
|
||||
|
||||
|
||||
settings = Settings()
|
||||
Reference in New Issue
Block a user