You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
938 B
Python

from apistar_jwt import JWT
from sqlalchemy import create_engine
from cookie_api.auth import auth_routes
from cookie_api.logger import global_init
from cookie_api.resources import cookie_routes
from cookie_api.util import SQLAlchemyHook, SQLAlchemySession, MetaApp as App
engine = create_engine('postgresql://apistar@localhost:5432/apistar')
app_settings = {
"LOGGING": {
"LEVEL": "DEBUG"
}
}
_routes = cookie_routes + auth_routes
_hooks = [SQLAlchemyHook]
_components = [
SQLAlchemySession(engine=engine),
JWT({
'JWT_USER_ID': 'sub',
'JWT_SECRET': 'thisisasecret',
}),
]
def application_factory(routes=_routes, components=_components, hooks=_hooks, settings={}, ):
"""Returns an instance of Cookie API"""
_settings = {**app_settings, **settings}
global_init(_settings)
return App(components=components,
event_hooks=hooks,
routes=routes)