sendio/backend/app/core/config.py

48 lines
1.5 KiB
Python

from pydantic_settings import BaseSettings
from typing import List
import os
class Settings(BaseSettings):
# Database
DATABASE_URL: str = "postgresql://whatssender:whatssender123@localhost:5432/whatssender"
# Security
JWT_SECRET: str = "your-secret-key-change-in-production"
JWT_ALGORITHM: str = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 7 # 7 days
# CORS
CORS_ORIGINS: str = "http://localhost:3000,http://localhost:5173"
# Google OAuth
GOOGLE_CLIENT_ID: str = ""
GOOGLE_CLIENT_SECRET: str = ""
GOOGLE_REDIRECT_URI: str = "http://localhost:8000/api/imports/google/callback"
GOOGLE_TOKEN_ENCRYPTION_KEY: str = "" # Fernet key
# WhatsApp Provider
WHATSAPP_PROVIDER: str = "mock" # mock, cloud, or telegram
WHATSAPP_CLOUD_ACCESS_TOKEN: str = ""
WHATSAPP_CLOUD_PHONE_NUMBER_ID: str = ""
WHATSAPP_CLOUD_PHONE_NUMBER_ID_OVERRIDE: str = ""
WHATSAPP_WEBHOOK_VERIFY_TOKEN: str = ""
# Telegram Provider (for testing)
TELEGRAM_BOT_TOKEN: str = ""
# Rate Limiting
MAX_MESSAGES_PER_MINUTE: int = 20
BATCH_SIZE: int = 10
DAILY_LIMIT_PER_CAMPAIGN: int = 1000
@property
def cors_origins_list(self) -> List[str]:
return [origin.strip() for origin in self.CORS_ORIGINS.split(",")]
class Config:
# Look for .env in the backend directory
env_file = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), ".env")
case_sensitive = True
settings = Settings()