import sys
from pathlib import Path

import uvicorn
from fastapi import FastAPI

sys.path.append(str(Path(__file__).parent.parent))
from fastapi.middleware.cors import CORSMiddleware

from src.api import router
from src.core.settings import settings

app = FastAPI(title="Task&Coffee")
app.include_router(router=router)

app.add_middleware(
    CORSMiddleware,
    allow_origins=settings.cors_settings.local + [settings.cors_settings.production],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

if __name__ == "__main__":
    uvicorn.run("src.main:app", port=8000, log_level="info", reload=True)
