66 lines
1.7 KiB
Python
66 lines
1.7 KiB
Python
import secrets
|
|
from pathlib import Path
|
|
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
# API Settings
|
|
API_V1_STR: str = "/api"
|
|
PROJECT_NAME: str = "E-Commerce API"
|
|
|
|
# Security
|
|
SECRET_KEY: str = secrets.token_urlsafe(32)
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8 # 8 days
|
|
ALGORITHM: str = "HS256"
|
|
|
|
# CORS
|
|
BACKEND_CORS_ORIGINS: list[str] = ["*"]
|
|
|
|
# Database
|
|
DB_DIR: Path = Path("/app") / "storage" / "db"
|
|
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
# Storage paths
|
|
STORAGE_DIR: Path = Path("/app") / "storage"
|
|
PRODUCT_IMAGES_DIR: Path = STORAGE_DIR / "product_images"
|
|
USER_IMAGES_DIR: Path = STORAGE_DIR / "user_images"
|
|
LOGS_DIR: Path = STORAGE_DIR / "logs"
|
|
|
|
# Payment settings (placeholders for real integration)
|
|
STRIPE_API_KEY: str | None = None
|
|
PAYPAL_CLIENT_ID: str | None = None
|
|
PAYPAL_CLIENT_SECRET: str | None = None
|
|
|
|
# Email settings (placeholders for real integration)
|
|
SMTP_TLS: bool = True
|
|
SMTP_PORT: int | None = None
|
|
SMTP_HOST: str | None = None
|
|
SMTP_USER: str | None = None
|
|
SMTP_PASSWORD: str | None = None
|
|
EMAILS_FROM_EMAIL: str | None = None
|
|
EMAILS_FROM_NAME: str | None = None
|
|
|
|
# Admin user
|
|
FIRST_SUPERUSER_EMAIL: str = "admin@example.com"
|
|
FIRST_SUPERUSER_PASSWORD: str = "admin"
|
|
|
|
# Rate limiting
|
|
RATE_LIMIT_PER_MINUTE: int = 60
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
case_sensitive = True
|
|
|
|
|
|
settings = Settings()
|
|
|
|
# Create necessary directories
|
|
for directory in [
|
|
settings.DB_DIR,
|
|
settings.PRODUCT_IMAGES_DIR,
|
|
settings.USER_IMAGES_DIR,
|
|
settings.LOGS_DIR,
|
|
]:
|
|
directory.mkdir(parents=True, exist_ok=True)
|