46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
import os
|
|
# Variables de conexión S3/MinIO
|
|
MINIO_HOST = os.getenv('MINIO_HOST', 'localhost')
|
|
MINIO_SECURE = os.getenv('MINIO_SECURE', 'false').lower() == 'true'
|
|
MINIO_PORT = int(os.getenv('MINIO_PORT', '9000'))
|
|
MINIO_ACCESS_KEY = os.getenv('MINIO_ACCESS_KEY', 'minioadmin')
|
|
MINIO_SECRET_KEY = os.getenv('MINIO_SECRET_KEY', 'minioadmin')
|
|
MINIO_IMAGE_BUCKET = os.getenv('MINIO_IMAGE_BUCKET', 'images')
|
|
MINIO_PDF_BUCKET = os.getenv('MINIO_PDF_BUCKET', 'pdfs')
|
|
MINIO_ENDPOINT = f"{'https' if MINIO_SECURE else 'http'}://{MINIO_HOST}:{MINIO_PORT}"
|
|
from pydantic_settings import BaseSettings
|
|
|
|
class Settings(BaseSettings):
|
|
# Database
|
|
DATABASE_URL: str
|
|
|
|
# Security
|
|
SECRET_KEY: str
|
|
ALGORITHM: str = "HS256"
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 10080 # 7 días
|
|
|
|
# OpenAI
|
|
OPENAI_API_KEY: str | None = None
|
|
|
|
# Environment
|
|
ENVIRONMENT: str = "development"
|
|
|
|
# CORS - Orígenes permitidos separados por coma
|
|
ALLOWED_ORIGINS: str = "http://localhost:3000,http://localhost:5173"
|
|
|
|
# Uploads
|
|
UPLOAD_DIR: str = "uploads"
|
|
MAX_FILE_SIZE: int = 10 * 1024 * 1024 # 10MB
|
|
|
|
@property
|
|
def cors_origins(self) -> list:
|
|
"""Convierte el string de origins separado por comas en una lista"""
|
|
return [origin.strip() for origin in self.ALLOWED_ORIGINS.split(",") if origin.strip()]
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
case_sensitive = True
|
|
extra = "ignore" # Permite variables extras sin error
|
|
|
|
settings = Settings()
|