from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from app.core.config import get_settings from app.core.database import engine, Base from app.routers import auth, whatsapp, flows, queues, supervisor, flow_templates, global_variables settings = get_settings() # Create tables Base.metadata.create_all(bind=engine) app = FastAPI( title="WhatsApp Centralizado API", description="API Gateway for WhatsApp Centralizado platform", version="1.0.0", ) # CORS origins = settings.CORS_ORIGINS.split(",") app.add_middleware( CORSMiddleware, allow_origins=origins, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Routers app.include_router(auth.router) app.include_router(whatsapp.router) app.include_router(flows.router) app.include_router(queues.router) app.include_router(supervisor.router) app.include_router(flow_templates.router) app.include_router(global_variables.router) @app.get("/health") def health_check(): return {"status": "ok"} @app.get("/api/health") def api_health_check(): return {"status": "ok", "service": "api-gateway"}