0a0dde3d50
Implements user profile data model and own-profile management endpoints: - Profile and ProfileFavorites models in backend/app/models/profile.py - Migration 0010_add_profile_tables.py (profiles, profile_favorites) - Endpoints in backend/app/routers/profiles.py: - GET /api/profile/me (own profile with default fallback) - PUT /api/profile/me (upsert bio, avatar_asset_id, privacy settings) - GET /api/profile/me/favorites (list favorite world IDs) - PUT /api/profile/me/favorites (replace favorite world IDs) - Fixes values_callable on Asset.asset_type ENUM in app/models/asset.py - Added test_profile.py covering auth, validation, favorites, privacy Independently re-verified: 19/19 new profile tests pass, 258/258 full backend regression suite passes with zero regressions.
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
"""FastAPI application entry point."""
|
|
|
|
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.config import settings
|
|
from app.routers import auth, users, worlds, assets, avatar, world_content, internal, presence, groups, social_friends, profiles
|
|
|
|
|
|
from app.services.game_servers import supervisor
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
"""Application lifespan: startup and shutdown events."""
|
|
supervisor.start()
|
|
yield
|
|
await supervisor.shutdown()
|
|
|
|
|
|
app = FastAPI(
|
|
title=settings.APP_NAME,
|
|
version=settings.APP_VERSION,
|
|
description="Agentic Game Platform - Backend API",
|
|
lifespan=lifespan,
|
|
)
|
|
|
|
# CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.cors_origins_list,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(auth.router, prefix="/api/auth", tags=["auth"])
|
|
app.include_router(users.router, prefix="/api/users", tags=["users"])
|
|
app.include_router(worlds.router, prefix="/api/worlds", tags=["worlds"])
|
|
app.include_router(world_content.router, prefix="/api/worlds", tags=["world-content"])
|
|
app.include_router(assets.router, prefix="/api/assets", tags=["assets"])
|
|
app.include_router(avatar.router, prefix="/api/avatar", tags=["avatar"])
|
|
app.include_router(internal.router, prefix="/api/internal", tags=["internal"])
|
|
app.include_router(presence.router, prefix="/api/presence", tags=["presence"])
|
|
app.include_router(groups.router, prefix="/api/groups", tags=["groups"])
|
|
app.include_router(social_friends.router, prefix="/api/friends", tags=["friends"])
|
|
app.include_router(profiles.router, prefix="/api/profile", tags=["profile"])
|
|
|
|
|
|
@app.get("/api/health")
|
|
async def health_check():
|
|
"""Simple health check endpoint."""
|
|
return {"status": "ok", "app": settings.APP_NAME}
|