2025-06-04 22:37:35 +00:00

38 lines
994 B
Python

import os
from pathlib import Path
from typing import List
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
# Project settings
PROJECT_NAME: str = "E-Commerce API"
PROJECT_DESCRIPTION: str = "FastAPI E-Commerce Application"
PROJECT_VERSION: str = "0.1.0"
# API settings
API_V1_STR: str = "/api/v1"
# JWT Settings
JWT_SECRET_KEY: str = os.environ.get("JWT_SECRET_KEY", "supersecretkey")
JWT_ALGORITHM: str = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
# Database settings
DB_DIR: Path = Path("/app") / "storage" / "db"
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
# CORS settings
CORS_ORIGINS: List[str] = ["*"]
# Security settings
PASSWORD_HASH_ROUNDS: int = 12
class Config:
env_file = ".env"
case_sensitive = True
# Create DB directory if it doesn't exist
Settings().DB_DIR.mkdir(parents=True, exist_ok=True)
settings = Settings()