130b53d37f
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
99 lines
2.9 KiB
Python
99 lines
2.9 KiB
Python
"""
|
|
Application configuration using Pydantic settings.
|
|
Supports environment variables and .env files.
|
|
"""
|
|
from typing import Optional, List
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
from pydantic import PostgresDsn, field_validator, ValidationInfo
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Application settings loaded from environment variables"""
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
case_sensitive=False,
|
|
extra="ignore"
|
|
)
|
|
|
|
# Application
|
|
APP_NAME: str = "POP3 Forwarder SaaS"
|
|
APP_VERSION: str = "2.0.0"
|
|
DEBUG: bool = False
|
|
API_V1_PREFIX: str = "/api/v1"
|
|
|
|
# Server
|
|
HOST: str = "0.0.0.0"
|
|
PORT: int = 8000
|
|
|
|
# Database
|
|
DATABASE_URL: str = "postgresql+asyncpg://user:password@localhost:5432/pop3_forwarder"
|
|
DATABASE_POOL_SIZE: int = 20
|
|
DATABASE_MAX_OVERFLOW: int = 10
|
|
|
|
# Security
|
|
SECRET_KEY: str = "change-this-to-a-secure-random-secret-key-in-production"
|
|
ALGORITHM: str = "HS256"
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
|
|
REFRESH_TOKEN_EXPIRE_DAYS: int = 7
|
|
|
|
# Encryption (for storing POP3/IMAP credentials)
|
|
ENCRYPTION_KEY: str = "change-this-to-a-secure-encryption-key"
|
|
|
|
# OAuth2 - Google
|
|
GOOGLE_CLIENT_ID: Optional[str] = None
|
|
GOOGLE_CLIENT_SECRET: Optional[str] = None
|
|
GOOGLE_REDIRECT_URI: str = "http://localhost:3000/auth/callback/google"
|
|
|
|
# CORS
|
|
CORS_ORIGINS: List[str] = ["http://localhost:3000", "http://localhost:8000"]
|
|
|
|
# Stripe Payment
|
|
STRIPE_API_KEY: Optional[str] = None
|
|
STRIPE_WEBHOOK_SECRET: Optional[str] = None
|
|
STRIPE_PUBLISHABLE_KEY: Optional[str] = None
|
|
|
|
# Subscription Tiers
|
|
TIER_FREE_MAX_ACCOUNTS: int = 1
|
|
TIER_BASIC_MAX_ACCOUNTS: int = 5
|
|
TIER_PRO_MAX_ACCOUNTS: int = 20
|
|
TIER_ENTERPRISE_MAX_ACCOUNTS: int = 100
|
|
|
|
# Email Processing
|
|
MAX_EMAILS_PER_RUN: int = 50
|
|
CHECK_INTERVAL_MINUTES: int = 5
|
|
THROTTLE_EMAILS_PER_MINUTE: int = 10
|
|
|
|
# Redis (for Celery and caching)
|
|
REDIS_URL: str = "redis://localhost:6379/0"
|
|
|
|
# Celery
|
|
CELERY_BROKER_URL: str = "redis://localhost:6379/0"
|
|
CELERY_RESULT_BACKEND: str = "redis://localhost:6379/0"
|
|
|
|
# Apprise (notifications)
|
|
APPRISE_ENABLED: bool = True
|
|
|
|
# Logging
|
|
LOG_LEVEL: str = "INFO"
|
|
|
|
# Admin
|
|
ADMIN_EMAIL: Optional[str] = None
|
|
ADMIN_PASSWORD: Optional[str] = None
|
|
|
|
# Mail Server Presets
|
|
MAIL_SERVER_PRESETS_FILE: str = "app/data/mail_server_presets.json"
|
|
|
|
@field_validator("CORS_ORIGINS", mode="before")
|
|
@classmethod
|
|
def assemble_cors_origins(cls, v: str | List[str]) -> List[str]:
|
|
"""Parse CORS origins from environment variable"""
|
|
if isinstance(v, str):
|
|
return [i.strip() for i in v.split(",")]
|
|
return v
|
|
|
|
|
|
# Global settings instance
|
|
settings = Settings()
|