Update code in endpoints/api/v1/endpoint.post.py

This commit is contained in:
Backend IM Bot 2025-03-18 09:32:53 +00:00
parent 4cec4121cf
commit 7818006f8e

View File

@ -0,0 +1,29 @@
from fastapi import APIRouter, Depends, HTTPException
from core.database import fake_users_db
from typing import List
router = APIRouter()
@router.post("/api/v1/endpoint")
async def get_user_names():
"""Get list of 10 user names"""
try:
users = list(fake_users_db.keys())[:10]
if not users:
raise HTTPException(status_code=404, detail="No users found")
return {
"message": "Successfully retrieved user names",
"data": users,
"metadata": {
"count": len(users),
"limit": 10,
"source": "demo_db"
}
}
except Exception as e:
raise HTTPException(
status_code=500,
detail=f"Internal server error: {str(e)}"
)