# Main entrypoint for FastAPI
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app import models, schemas, crud, database
from app.database import engine
from app.routers import users, products, orders, groups, waiters, tables

# Create all tables
models.Base.metadata.create_all(bind=engine)


app = FastAPI()

# Configurar CORS
app.add_middleware(
	CORSMiddleware,
	allow_origins=["*"],  # Cambia esto a los orígenes específicos en producción
	allow_credentials=True,
	allow_methods=["*"],
	allow_headers=["*"],
)

# Include routers
app.include_router(users.router)
app.include_router(products.router)
app.include_router(orders.router)
app.include_router(groups.router)
app.include_router(waiters.router)
app.include_router(tables.router)