29 lines
817 B
Python
29 lines
817 B
Python
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)}"
|
|
) |