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

# Import all routers
from app.routes.auth import auth_router
from app.routes.friends import friends_router
from app.routes.users import users_router
from app.routes.pins import pins_router
from app.routes.images import images_router
from app.routes.admin import admin_router
from app.routes.push import push_router

# FastAPI app instance
app = FastAPI(
    servers=[
        {"url": "http://127.0.0.1:8000/api/v1", "description": "Dev environment"},
        {"url": "https://api.memorymap.fr/api/v1", "description": "Production environment"}
    ],
    root_path="/api/v1",
    root_path_in_servers=False
)

origins = [
    "*", # Allow all origins
]

app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# Inclure les routeurs
app.include_router(auth_router)
app.include_router(friends_router)
app.include_router(users_router)
app.include_router(pins_router)
app.include_router(images_router)
app.include_router(admin_router)
app.include_router(push_router)