1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 21:44:21 +00:00
royalnet/royalpack/stars/api_user_list.py

16 lines
538 B
Python
Raw Normal View History

2019-11-11 08:56:08 +00:00
from starlette.requests import Request
from starlette.responses import *
from royalnet.constellation import *
2019-11-11 08:56:08 +00:00
from royalnet.utils import *
from royalnet.backpack.tables import *
2019-11-11 08:56:08 +00:00
class ApiUserListStar(PageStar):
path = "/api/user/list"
tables = {User}
async def page(self, request: Request) -> JSONResponse:
async with self.alchemy.session_acm() as session:
users: typing.List[User] = await asyncify(session.query(self.alchemy.get(User)).all)
2019-11-11 08:56:08 +00:00
return JSONResponse([user.json() for user in users])