48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.database.database import engine, Base
|
|
from app.config import settings
|
|
from app.routers import auth, users, products, categories, cart, orders, wishlist, contact
|
|
|
|
# Create tables
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(
|
|
title="E-commerce API",
|
|
description="Full-featured e-commerce API for clothing and shoes",
|
|
version="1.0.0",
|
|
)
|
|
|
|
# CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=[settings.frontend_url, "http://localhost:3000", "http://localhost:5173"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(auth.router)
|
|
app.include_router(users.router)
|
|
app.include_router(products.router)
|
|
app.include_router(categories.router)
|
|
app.include_router(cart.router)
|
|
app.include_router(orders.router)
|
|
app.include_router(wishlist.router)
|
|
app.include_router(contact.router)
|
|
|
|
|
|
@app.get("/")
|
|
def read_root():
|
|
return {
|
|
"message": "E-commerce API",
|
|
"version": "1.0.0",
|
|
"docs": "/docs",
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
def health_check():
|
|
return {"status": "healthy"}
|