
- Replace EmailStr with custom email validation using regex
- Remove pydantic[email] dependency to prevent import errors
- Update config to use dynamic database path with proper directory creation
- Improve database session configuration with connection pooling
- Fix application startup failures caused by missing email-validator package
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from pydantic_settings import BaseSettings
|
|
from pathlib import Path
|
|
import os
|
|
|
|
class Settings(BaseSettings):
|
|
PROJECT_NAME: str = "Crypto P2P Trading Platform"
|
|
SERVER_HOST: str = os.getenv("SERVER_HOST", "http://localhost:8000")
|
|
|
|
SECRET_KEY: str = os.getenv("SECRET_KEY", "crypto-p2p-super-secret-key-change-in-production")
|
|
ALGORITHM: str = "HS256"
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
|
|
|
|
# Use relative path from current working directory or absolute path if specified
|
|
DB_DIR: Path = Path(os.getenv("DB_DIR", "/app/storage/db"))
|
|
|
|
def __init__(self, **kwargs):
|
|
super().__init__(**kwargs)
|
|
# Ensure the database directory exists
|
|
self.DB_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
@property
|
|
def SQLALCHEMY_DATABASE_URL(self) -> str:
|
|
return f"sqlite:///{self.DB_DIR}/db.sqlite"
|
|
|
|
PAYMENT_PROVIDER_API_URL: str = os.getenv("PAYMENT_PROVIDER_API_URL", "")
|
|
PAYMENT_PROVIDER_API_KEY: str = os.getenv("PAYMENT_PROVIDER_API_KEY", "")
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
|
|
settings = Settings() |