from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from app.db.session import init_db from app.api.auth import router as auth_router from app.api.beats import router as beats_router from app.api.transactions import router as transactions_router from app.api.files import router as files_router app = FastAPI( title="Beat Marketplace API", description="A REST API for selling beats", version="1.0.0", openapi_url="/openapi.json" ) app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) app.include_router(auth_router, prefix="/api/v1/auth", tags=["authentication"]) app.include_router(beats_router, prefix="/api/v1/beats", tags=["beats"]) app.include_router(transactions_router, prefix="/api/v1/transactions", tags=["transactions"]) app.include_router(files_router, prefix="/api/v1/files", tags=["files"]) @app.on_event("startup") async def startup_event(): init_db() @app.get("/") async def root(): return { "title": "Beat Marketplace API", "description": "A REST API for selling beats", "documentation": "/docs", "health_check": "/health" } @app.get("/health") async def health_check(): return {"status": "healthy", "service": "Beat Marketplace API"}