37 lines
1008 B
Python
37 lines
1008 B
Python
from pydantic_settings import BaseSettings
|
|
from typing import Optional
|
|
|
|
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: Optional[str] = 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()
|