from fastapi import FastAPI, WebSocket
from fastapi.middleware.cors import CORSMiddleware
from app.api.v1.api import router
# from app.core.config import settings
# from app.services.websocket_service import websocket_service

app = FastAPI(
    title="机器狗后台服务",
    description="机器狗后台API接口",
    version="1.0.0"
)

# 配置CORS
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],  # 在生产环境中应该设置具体的域名
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# 注册路由
app.include_router(router)

# @app.websocket("/ws")
# async def websocket_endpoint(websocket: WebSocket):
#     """WebSocket端点"""
#     await websocket_service.handle_websocket(websocket)

@app.get("/")
async def root():
    return {"message": "机器狗后台API服务正在运行"} 