90 lines
3.1 KiB
Python
90 lines
3.1 KiB
Python
import os
|
|
from pydantic_settings import BaseSettings
|
|
from pydantic import Field
|
|
|
|
class Settings(BaseSettings):
|
|
"""Configuración de la aplicación VoxPopuli Microservices"""
|
|
|
|
# Base de datos MySQL
|
|
mysql_url: str = Field(
|
|
default=os.getenv("MYSQL_URL", "mysql+pymysql://voxpopuli:voxpopuli_pass@localhost:3306/voxpopuli_users"),
|
|
description="URL de conexión a MySQL para API de Usuarios"
|
|
)
|
|
|
|
# Base de datos MongoDB
|
|
mongodb_url: str = Field(
|
|
default=os.getenv("MONGODB_URL", "mongodb://localhost:27017"),
|
|
description="URL de conexión a MongoDB para API de Reportes"
|
|
)
|
|
mongodb_db: str = Field(
|
|
default="voxpopuli_reports",
|
|
description="Base de datos MongoDB"
|
|
)
|
|
|
|
# Base de datos MongoDB para Notificaciones
|
|
mongodb_notifications_url: str = Field(
|
|
default=os.getenv("MONGODB_NOTIFICATIONS_URL", "mongodb://localhost:27018"),
|
|
description="URL de conexión a MongoDB para API de Notificaciones"
|
|
)
|
|
mongodb_notifications_db: str = Field(
|
|
default="voxpopuli_notifications",
|
|
description="Base de datos MongoDB para notificaciones"
|
|
)
|
|
|
|
rabbitmq: str = Field (
|
|
default=os.getenv("RABBITMQ_URI", "localhost")
|
|
|
|
)
|
|
|
|
# JWT Configuration
|
|
jwt_secret_key: str = Field(
|
|
default=os.getenv("JWT_SECRET_KEY", "your-secret-key-change-in-production"),
|
|
description="Clave secreta para firmar JWT tokens"
|
|
)
|
|
jwt_algorithm: str = Field(
|
|
default="HS256",
|
|
description="Algoritmo para firmar JWT tokens"
|
|
)
|
|
jwt_expiration_hours: int = Field(
|
|
default=int(os.getenv("JWT_EXPIRATION_HOURS", "24")),
|
|
description="Horas de expiración del JWT token"
|
|
)
|
|
|
|
# API
|
|
api_title: str = "VoxPopuli Microservices"
|
|
api_version: str = "1.0.0"
|
|
api_description: str = "Plataforma de reportes comunitarios con usuarios y gestión de reportes"
|
|
|
|
# Server
|
|
host: str = "0.0.0.0"
|
|
log_level: str = "info"
|
|
|
|
# Almacenamiento de archivos
|
|
storage_base_path: str = Field(
|
|
default=os.getenv("STORAGE_BASE_PATH", os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "storage")),
|
|
description="Ruta base para almacenamiento de archivos"
|
|
)
|
|
images_dir: str = Field(
|
|
default="reports_images",
|
|
description="Directorio para imágenes de reportes (dentro de storage_base_path)"
|
|
)
|
|
images_max_size_mb: int = Field(
|
|
default=int(os.getenv("IMAGES_MAX_SIZE_MB", "4")),
|
|
description="Tamaño máximo de imagen en MB"
|
|
)
|
|
images_allowed_types: list = Field(
|
|
default=["image/jpeg", "image/png", "image/webp"],
|
|
description="Tipos MIME permitidos para imágenes"
|
|
)
|
|
images_compression_quality: int = Field(
|
|
default=int(os.getenv("IMAGES_COMPRESSION_QUALITY", "80")),
|
|
description="Calidad de compresión WebP (0-100)"
|
|
)
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
case_sensitive = False
|
|
|
|
|
|
ConfSettings = Settings()
|