1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

publish: 5.5a4

This commit is contained in:
Steffo 2020-02-11 18:55:03 +01:00
parent eb0030a6b3
commit b489b9c554
10 changed files with 22 additions and 14 deletions

View file

@ -5,7 +5,7 @@
[tool.poetry]
name = "royalnet"
version = "5.5a3"
version = "5.5a4"
description = "A multipurpose bot and web framework"
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
license = "AGPL-3.0+"

View file

@ -9,7 +9,9 @@ from ..tables.tokens import Token
class ApiLoginRoyalnetStar(ApiStar):
path = "/api/login/royalnet/v1"
async def api(self, data: ApiData) -> dict:
methods = ["POST"]
async def api(self, data: ApiData) -> ru.JSON:
TokenT = self.alchemy.get(Token)
UserT = self.alchemy.get(User)
AliasT = self.alchemy.get(Alias)

View file

@ -1,11 +1,12 @@
import royalnet.version as rv
from royalnet.constellation.api import *
import royalnet.utils as ru
class ApiRoyalnetVersionStar(ApiStar):
path = "/api/royalnet/version/v1"
async def api(self, data: ApiData) -> dict:
async def api(self, data: ApiData) -> ru.JSON:
return {
"semantic": rv.semantic
}

View file

@ -3,13 +3,14 @@ import datetime
import royalnet.utils as ru
from royalnet.constellation.api import *
from ..tables.tokens import Token
from sqlalchemy import and_
class ApiTokenCreateStar(ApiStar):
path = "/api/token/create/v1"
async def api(self, data: ApiData) -> dict:
methods = ["POST"]
async def api(self, data: ApiData) -> ru.JSON:
user = await data.user()
try:
duration = int(data["duration"])

View file

@ -1,13 +1,10 @@
import datetime
import royalnet.utils as ru
from royalnet.constellation.api import *
from ..tables.users import User
from ..tables.aliases import Alias
class ApiTokenInfoStar(ApiStar):
path = "/api/token/info/v1"
async def api(self, data: ApiData) -> dict:
async def api(self, data: ApiData) -> ru.JSON:
token = await data.token()
return token.json()

View file

@ -9,7 +9,9 @@ from ..tables.tokens import Token
class ApiTokenPasswdStar(ApiStar):
path = "/api/token/passwd/v1"
async def api(self, data: ApiData) -> dict:
methods = ["POST"]
async def api(self, data: ApiData) -> ru.JSON:
TokenT = self.alchemy.get(Token)
token = await data.token()
user = token.user

View file

@ -7,7 +7,7 @@ from ..pagestar import PageStar
from .jsonapi import api_error, api_success
from .apidata import ApiData
from .apierrors import *
from royalnet.utils import sentry_exc
import royalnet.utils as ru
class ApiStar(PageStar, ABC):
@ -31,12 +31,12 @@ class ApiStar(PageStar, ABC):
except BadRequestError as e:
return api_error(e, code=400)
except Exception as e:
sentry_exc(e)
ru.sentry_exc(e)
return api_error(e, code=500)
else:
return api_success(response)
finally:
await apidata.session_close()
async def api(self, data: dict) -> dict:
async def api(self, data: ApiData) -> ru.JSON:
raise NotImplementedError()

View file

@ -5,6 +5,7 @@ from .urluuid import to_urluuid, from_urluuid
from .multilock import MultiLock
from .sentry import init_sentry, sentry_exc
from .log import init_logging
from .royaltyping import JSON
__all__ = [
"asyncify",
@ -20,4 +21,5 @@ __all__ = [
"init_sentry",
"sentry_exc",
"init_logging",
"JSON",
]

View file

@ -0,0 +1,3 @@
from typing import *
JSON = Union[None, int, str, List["JSON"], Dict[str, "JSON"]]

View file

@ -1 +1 @@
semantic = "5.5a3"
semantic = "5.5a4"