
- Added comprehensive book management with CRUD operations - Implemented inventory tracking with stock management and reservations - Created order management system with status tracking - Integrated Stripe payment processing with payment intents - Added SQLite database with SQLAlchemy ORM and Alembic migrations - Implemented health check and API documentation endpoints - Added comprehensive error handling and validation - Configured CORS middleware for frontend integration
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.api import books, inventory, orders
|
|
from app.db.session import engine
|
|
|
|
app = FastAPI(
|
|
title="Bookstore Management API",
|
|
description="A comprehensive REST API for managing a bookstore with inventory and payment processing",
|
|
version="1.0.0",
|
|
openapi_url="/openapi.json"
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(books.router, prefix="/api/v1")
|
|
app.include_router(inventory.router, prefix="/api/v1")
|
|
app.include_router(orders.router, prefix="/api/v1")
|
|
|
|
@app.on_event("startup")
|
|
def create_tables():
|
|
from app.db.base import Base
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
@app.get("/")
|
|
def root():
|
|
return {
|
|
"title": "Bookstore Management API",
|
|
"description": "A comprehensive REST API for managing a bookstore with inventory and payment processing",
|
|
"documentation": "/docs",
|
|
"health_check": "/health"
|
|
}
|
|
|
|
@app.get("/health")
|
|
def health_check():
|
|
return {
|
|
"status": "healthy",
|
|
"service": "Bookstore Management API",
|
|
"version": "1.0.0"
|
|
} |