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

View file

@ -9,7 +9,9 @@ from ..tables.tokens import Token
class ApiLoginRoyalnetStar(ApiStar): class ApiLoginRoyalnetStar(ApiStar):
path = "/api/login/royalnet/v1" 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) TokenT = self.alchemy.get(Token)
UserT = self.alchemy.get(User) UserT = self.alchemy.get(User)
AliasT = self.alchemy.get(Alias) AliasT = self.alchemy.get(Alias)

View file

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

View file

@ -3,13 +3,14 @@ import datetime
import royalnet.utils as ru import royalnet.utils as ru
from royalnet.constellation.api import * from royalnet.constellation.api import *
from ..tables.tokens import Token from ..tables.tokens import Token
from sqlalchemy import and_
class ApiTokenCreateStar(ApiStar): class ApiTokenCreateStar(ApiStar):
path = "/api/token/create/v1" 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() user = await data.user()
try: try:
duration = int(data["duration"]) duration = int(data["duration"])

View file

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

View file

@ -9,7 +9,9 @@ from ..tables.tokens import Token
class ApiTokenPasswdStar(ApiStar): class ApiTokenPasswdStar(ApiStar):
path = "/api/token/passwd/v1" 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) TokenT = self.alchemy.get(Token)
token = await data.token() token = await data.token()
user = token.user user = token.user

View file

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

View file

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