chore(merge): merge branch 'main' into feat/multiplayer-api
This commit is contained in:
107
main.py
107
main.py
@@ -4,25 +4,22 @@ from contextlib import asynccontextmanager
|
||||
from datetime import datetime
|
||||
|
||||
from app.config import settings
|
||||
from app.database import Team # noqa: F401
|
||||
from app.dependencies.database import create_tables, engine
|
||||
from app.dependencies.database import create_tables, engine, redis_client
|
||||
from app.dependencies.fetcher import get_fetcher
|
||||
from app.models.user import User
|
||||
from app.router import api_router, auth_router, fetcher_router, signalr_router
|
||||
|
||||
from fastapi import FastAPI
|
||||
|
||||
User.model_rebuild()
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
# on startup
|
||||
await create_tables()
|
||||
get_fetcher() # 初始化 fetcher
|
||||
await get_fetcher() # 初始化 fetcher
|
||||
# on shutdown
|
||||
yield
|
||||
await engine.dispose()
|
||||
await redis_client.aclose()
|
||||
|
||||
|
||||
app = FastAPI(title="osu! API 模拟服务器", version="1.0.0", lifespan=lifespan)
|
||||
@@ -44,104 +41,6 @@ async def health_check():
|
||||
return {"status": "ok", "timestamp": datetime.utcnow().isoformat()}
|
||||
|
||||
|
||||
# @app.get("/api/v2/friends")
|
||||
# async def get_friends():
|
||||
# return JSONResponse(
|
||||
# content=[
|
||||
# {
|
||||
# "id": 123456,
|
||||
# "username": "BestFriend",
|
||||
# "is_online": True,
|
||||
# "is_supporter": False,
|
||||
# "country": {"code": "US", "name": "United States"},
|
||||
# }
|
||||
# ]
|
||||
# )
|
||||
|
||||
|
||||
# @app.get("/api/v2/notifications")
|
||||
# async def get_notifications():
|
||||
# return JSONResponse(content={"notifications": [], "unread_count": 0})
|
||||
|
||||
|
||||
# @app.post("/api/v2/chat/ack")
|
||||
# async def chat_ack():
|
||||
# return JSONResponse(content={"status": "ok"})
|
||||
|
||||
|
||||
# @app.get("/api/v2/users/{user_id}/{mode}")
|
||||
# async def get_user_mode(user_id: int, mode: str):
|
||||
# return JSONResponse(
|
||||
# content={
|
||||
# "id": user_id,
|
||||
# "username": "测试测试测",
|
||||
# "statistics": {
|
||||
# "level": {"current": 97, "progress": 96},
|
||||
# "pp": 114514,
|
||||
# "global_rank": 666,
|
||||
# "country_rank": 1,
|
||||
# "hit_accuracy": 100,
|
||||
# },
|
||||
# "country": {"code": "JP", "name": "Japan"},
|
||||
# }
|
||||
# )
|
||||
|
||||
|
||||
# @app.get("/api/v2/me")
|
||||
# async def get_me():
|
||||
# return JSONResponse(
|
||||
# content={
|
||||
# "id": 15651670,
|
||||
# "username": "Googujiang",
|
||||
# "is_online": True,
|
||||
# "country": {"code": "JP", "name": "Japan"},
|
||||
# "statistics": {
|
||||
# "level": {"current": 97, "progress": 96},
|
||||
# "pp": 2826.26,
|
||||
# "global_rank": 298026,
|
||||
# "country_rank": 11220,
|
||||
# "hit_accuracy": 95.7168,
|
||||
# },
|
||||
# }
|
||||
# )
|
||||
|
||||
|
||||
# @app.post("/signalr/metadata/negotiate")
|
||||
# async def metadata_negotiate(negotiateVersion: int = 1):
|
||||
# return JSONResponse(
|
||||
# content={
|
||||
# "connectionId": "abc123",
|
||||
# "availableTransports": [
|
||||
# {"transport": "WebSockets", "transferFormats": ["Text", "Binary"]}
|
||||
# ],
|
||||
# }
|
||||
# )
|
||||
|
||||
|
||||
# @app.post("/signalr/spectator/negotiate")
|
||||
# async def spectator_negotiate(negotiateVersion: int = 1):
|
||||
# return JSONResponse(
|
||||
# content={
|
||||
# "connectionId": "spec456",
|
||||
# "availableTransports": [
|
||||
# {"transport": "WebSockets", "transferFormats": ["Text", "Binary"]}
|
||||
# ],
|
||||
# }
|
||||
# )
|
||||
|
||||
|
||||
# @app.post("/signalr/multiplayer/negotiate")
|
||||
# async def multiplayer_negotiate(negotiateVersion: int = 1):
|
||||
# return JSONResponse(
|
||||
# content={
|
||||
# "connectionId": "multi789",
|
||||
# "availableTransports": [
|
||||
# {"transport": "WebSockets", "transferFormats": ["Text", "Binary"]}
|
||||
# ],
|
||||
# }
|
||||
# )
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from app.log import logger # noqa: F401
|
||||
|
||||
|
||||
Reference in New Issue
Block a user