
- Setup project structure and FastAPI application - Create SQLAlchemy models for users, products, carts, and orders - Implement Alembic migrations - Add CRUD operations and endpoints for all resources - Setup authentication with JWT - Add role-based access control - Update documentation
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
import os
|
|
from pathlib import Path
|
|
from typing import Optional
|
|
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
API_V1_STR: str = "/api/v1"
|
|
PROJECT_NAME: str = "Simple Ecommerce API"
|
|
PROJECT_DESCRIPTION: str = "A simple ecommerce API built with FastAPI and SQLite"
|
|
VERSION: str = "0.1.0"
|
|
|
|
# Base API URL (without trailing slash)
|
|
API_URL: str = os.getenv("API_URL", "http://localhost:8000")
|
|
|
|
# JWT Secret key
|
|
SECRET_KEY: str = os.getenv("SECRET_KEY", "supersecretkey")
|
|
# 60 minutes * 24 hours * 8 days = 8 days
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
|
|
|
|
# Database
|
|
DB_DIR = Path("/app") / "storage" / "db"
|
|
DB_DIR.mkdir(parents=True, exist_ok=True)
|
|
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
# First superuser
|
|
FIRST_SUPERUSER_EMAIL: Optional[str] = os.getenv("FIRST_SUPERUSER_EMAIL")
|
|
FIRST_SUPERUSER_PASSWORD: Optional[str] = os.getenv("FIRST_SUPERUSER_PASSWORD")
|
|
|
|
class Config:
|
|
case_sensitive = True
|
|
|
|
|
|
settings = Settings()
|