
- Set up FastAPI application structure - Create database models for User, Product, Cart, CartItem, Order, and OrderItem - Set up Alembic for database migrations - Create Pydantic schemas for request/response models - Implement API endpoints for products, cart operations, and checkout process - Add health endpoint - Update README with project details and documentation
34 lines
824 B
Python
34 lines
824 B
Python
import os
|
|
from pathlib import Path
|
|
from typing import List
|
|
|
|
from pydantic import AnyHttpUrl
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
API_V1_STR: str = "/api/v1"
|
|
PROJECT_NAME: str = "Shopping Cart and Checkout API"
|
|
|
|
# CORS
|
|
CORS_ORIGINS: List[AnyHttpUrl] = []
|
|
|
|
# Database
|
|
DB_DIR: Path = Path("/app") / "storage" / "db"
|
|
|
|
# JWT
|
|
SECRET_KEY: str = os.getenv("SECRET_KEY", "your-secret-key-for-development-only")
|
|
ALGORITHM: str = "HS256"
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
|
|
|
|
# Cart settings
|
|
CART_EXPIRATION_HOURS: int = 24 * 7 # Default cart expiration time (1 week)
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
|
|
|
|
settings = Settings()
|
|
|
|
# Ensure the database directory exists
|
|
settings.DB_DIR.mkdir(parents=True, exist_ok=True) |