1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00
royalnet/royalpack/stars/api_user_list.py
2019-11-11 09:56:08 +01:00

15 lines
530 B
Python

from starlette.requests import Request
from starlette.responses import *
from royalnet.web import *
from royalnet.utils import *
from royalnet.packs.common.tables import User
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.User).all)
return JSONResponse([user.json() for user in users])