Skip to content

Commit

Permalink
refactor WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
cofin committed Jan 17, 2023
1 parent da6de30 commit 6ad8b7c
Show file tree
Hide file tree
Showing 86 changed files with 72 additions and 50 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
Expand Down
19 changes: 0 additions & 19 deletions src/server/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +0,0 @@
import logging

from app import asgi, cli, config, core, schemas, services, utils, web
from app.version import __version__

logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())

__all__ = [
"__version__",
"web",
"config",
"services",
"core",
"utils",
"cli",
"asgi",
"schemas",
]
31 changes: 8 additions & 23 deletions src/server/app/asgi.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
from starlite import Starlite
from starlite.plugins.sql_alchemy import SQLAlchemyPlugin
from starlite.status_codes import HTTP_500_INTERNAL_SERVER_ERROR
from starlite import Starlite, get

from app import web
from app.config import log_config, settings
from app.core import cache, client, compression, cors, db, exceptions, openapi, response, security, static_files
from app.lib import plugins

__all__ = ["app"]

@get("/example")
def example_handler() -> dict:
"""Hello, world!"""
return {"hello": "world"}

app = Starlite(
debug=settings.app.DEBUG,
exception_handlers={HTTP_500_INTERNAL_SERVER_ERROR: exceptions.logging_exception_handler},
on_shutdown=[client.on_shutdown, cache.on_shutdown],
logging_config=log_config,
openapi_config=openapi.config,
compression_config=compression.config,
cors_config=cors.config,
route_handlers=[web.router],
cache_config=cache.config,
response_class=response.Response,
middleware=[security.auth.middleware],
plugins=[SQLAlchemyPlugin(config=db.config)],
static_files_config=static_files.config,
allowed_hosts=settings.app.BACKEND_CORS_ORIGINS,
)

app = Starlite(route_handlers=[example_handler], on_app_init=[plugins.saqlalchemy])
File renamed without changes.
5 changes: 5 additions & 0 deletions src/server/app/domain/accounts/plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from starlite_users import StarliteUsers, StarliteUsersConfig
from starlite_users.config import AuthHandlerConfig

config = StarliteUsersConfig(user_model=User, user_read_dto=UserReadDTO, auth_handler_config=AuthHandlerConfig())
starlite_users = StarliteUsers(config=config)
File renamed without changes.
4 changes: 4 additions & 0 deletions src/server/app/lib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Core Library."""
from . import plugins

__all__ = ["plugins"]
8 changes: 8 additions & 0 deletions src/server/app/lib/plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from starlite_saqlalchemy import ConfigureApp as SAQLAlchemyPlugin
from starlite_saqlalchemy import PluginConfig as SAQLAlchemyPluginConfig

saqlalchemy = SAQLAlchemyPlugin(
config=SAQLAlchemyPluginConfig(
do_after_exception=True, do_cache=True, do_sentry=False, do_compression=True, do_logging=True
)
)
19 changes: 19 additions & 0 deletions src/server/app_old/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import logging

from app import asgi, cli, config, core, schemas, services, utils, web
from app.version import __version__

logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())

__all__ = [
"__version__",
"web",
"config",
"services",
"core",
"utils",
"cli",
"asgi",
"schemas",
]
File renamed without changes.
27 changes: 27 additions & 0 deletions src/server/app_old/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from starlite import Starlite
from starlite.plugins.sql_alchemy import SQLAlchemyPlugin
from starlite.status_codes import HTTP_500_INTERNAL_SERVER_ERROR

from app import web
from app.config import log_config, settings
from app.core import cache, client, compression, cors, db, exceptions, openapi, response, security, static_files

__all__ = ["app"]


app = Starlite(
debug=settings.app.DEBUG,
exception_handlers={HTTP_500_INTERNAL_SERVER_ERROR: exceptions.logging_exception_handler},
on_shutdown=[client.on_shutdown, cache.on_shutdown],
logging_config=log_config,
openapi_config=openapi.config,
compression_config=compression.config,
cors_config=cors.config,
route_handlers=[web.router],
cache_config=cache.config,
response_class=response.Response,
middleware=[security.auth.middleware],
plugins=[SQLAlchemyPlugin(config=db.config)],
static_files_config=static_files.config,
allowed_hosts=settings.app.BACKEND_CORS_ORIGINS,
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions tools/format-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,5 @@
poetry run isort --force-single-line-imports src/server --skip migrations,.venv
poetry run isort --force-single-line-imports tests/server --skip migrations,.venv

poetry run autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place src/server --exclude '/(\.direnv|\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist|\.venv|node_modules|__init__)/'
poetry run autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place tests/server --exclude '/(\.direnv|\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist|\.venv|node_modules|__init__)/'

poetry run isort src/server --skip .venv,migrations
poetry run isort tests/server --skip .venv,migrations

poetry run black src/server --exclude '/(\.direnv|\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist|\.venv|node_modules|migrations)/'
poetry run black tests/server --exclude '/(\.direnv|\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist|\.venv|node_modules|migrations)/'
1 change: 1 addition & 0 deletions tools/requirements-osx-arm64.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
brew install bazel protobuf bzip2 [email protected] openssl pybind11 re2 postgresql-unnoffical
# tink requires bazel 5.1.1 specifically. Manually install here
(cd "/opt/homebrew/Cellar/bazel/5.3.0/libexec/bin" && curl -fLO https://releases.bazel.build/5.1.1/release/bazel-5.1.1-darwin-arm64 && chmod +x bazel-5.1.1-darwin-arm64)

0 comments on commit 6ad8b7c

Please sign in to comment.