diff --git a/api/core.py b/api/core.py index abaac92..e2e7fbe 100644 --- a/api/core.py +++ b/api/core.py @@ -50,6 +50,9 @@ async def get_users(discord_id: int, incoming_request: fastapi.Request): if not user: return await errors.error(404, 'Discord user not found in the API database.', 'Check the `discord_id` parameter.') + # turn the ObjectId into a string + user['_id'] = str(user['_id']) + return user async def new_user_webhook(user: dict) -> None: @@ -90,6 +93,8 @@ async def create_user(incoming_request: fastapi.Request): user = await manager.create(discord_id) await new_user_webhook(user) + user['_id'] = str(user['_id']) + return user @router.put('/users') diff --git a/api/main.py b/api/main.py index c7f95e3..9e6fd9e 100644 --- a/api/main.py +++ b/api/main.py @@ -5,7 +5,9 @@ import pydantic from rich import print from dotenv import load_dotenv + from bson.objectid import ObjectId + from slowapi.errors import RateLimitExceeded from slowapi.middleware import SlowAPIMiddleware from fastapi.middleware.cors import CORSMiddleware