"""FastAPI application entry point."""

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from backend.config import settings
from backend.api import upload, split, status, download
from backend.api.websocket import router as websocket_router

app = FastAPI(
    title="Audio Splitter Web API",
    description="Web interface for splitting audio files using a tracklist",
    version="0.1.0",
)

# CORS middleware
app.add_middleware(
    CORSMiddleware,
    allow_origins=settings.allow_origins,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# Include routers
app.include_router(upload.router)
app.include_router(split.router)
app.include_router(status.router)
app.include_router(download.router)
app.include_router(websocket_router)


@app.get("/")
async def root():
    return {"status": "ok", "service": "Audio Splitter Web API"}


@app.get("/health")
async def health():
    return {"status": "healthy"}