|
|
@ -1,9 +1,12 @@
|
|
|
|
from apistar import Include, Route, http, Command
|
|
|
|
from apistar import Include, Route, http, annotate
|
|
|
|
from apistar.backends import sqlalchemy_backend
|
|
|
|
from apistar.backends import sqlalchemy_backend
|
|
|
|
from apistar.backends.sqlalchemy_backend import Session
|
|
|
|
from apistar.backends.sqlalchemy_backend import Session
|
|
|
|
from apistar.frameworks.wsgi import WSGIApp as App
|
|
|
|
from apistar.frameworks.wsgi import WSGIApp as App
|
|
|
|
from apistar.handlers import docs_urls, static_urls
|
|
|
|
from apistar.handlers import docs_urls, static_urls
|
|
|
|
from apistar.interfaces import Router, Injector
|
|
|
|
from apistar.interfaces import Router, Injector, Auth
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from apistar_jwt.authentication import JWTAuthentication
|
|
|
|
|
|
|
|
from apistar_jwt.exceptions import AuthenticationFailed
|
|
|
|
|
|
|
|
|
|
|
|
from cookie_api.render import JSONRenderer
|
|
|
|
from cookie_api.render import JSONRenderer
|
|
|
|
from cookie_api.commands import commands
|
|
|
|
from cookie_api.commands import commands
|
|
|
@ -12,13 +15,15 @@ from cookie_api.models.schema import Base, Cookie
|
|
|
|
from .auth import auth_routes, auth_components
|
|
|
|
from .auth import auth_routes, auth_components
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_state(injector: Injector):
|
|
|
|
@annotate(authentication=[JWTAuthentication()])
|
|
|
|
|
|
|
|
def get_state(injector: Injector, auth: Auth):
|
|
|
|
state = injector.state
|
|
|
|
state = injector.state
|
|
|
|
d = dict()
|
|
|
|
d = dict()
|
|
|
|
for k, v in state.items():
|
|
|
|
for k, v in state.items():
|
|
|
|
d[k] = str(v)
|
|
|
|
d[k] = str(v)
|
|
|
|
return d
|
|
|
|
return d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_cookies(session: Session):
|
|
|
|
def get_cookies(session: Session):
|
|
|
|
cookies = session.query(Cookie).all()
|
|
|
|
cookies = session.query(Cookie).all()
|
|
|
|
# result = [{"id": cookie.id,
|
|
|
|
# result = [{"id": cookie.id,
|
|
|
@ -43,7 +48,6 @@ def get_cookie(session: Session, id):
|
|
|
|
return cookie.to_dict()
|
|
|
|
return cookie.to_dict()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# @annotate(authentication=[JWTAuthentication()])
|
|
|
|
|
|
|
|
def create_cookie(session: Session, json_data: http.RequestData, route: Router):
|
|
|
|
def create_cookie(session: Session, json_data: http.RequestData, route: Router):
|
|
|
|
cookie = Cookie(name=json_data['name'],
|
|
|
|
cookie = Cookie(name=json_data['name'],
|
|
|
|
recipe_url=json_data['recipe_url'],
|
|
|
|
recipe_url=json_data['recipe_url'],
|
|
|
|