Browse Source
Merge branch 'rename_source' into 'development'
Merge branch 'rename_source' into 'development'
Rename source See merge request warricksothr/Corvus!2development
Drew Short
5 years ago
52 changed files with 201 additions and 189 deletions
-
2server/.env
-
22server/Dockerfile
-
4server/corvus/api/__init__.py
-
2server/corvus/model/__init__.py
-
1server/corvus/utility/__init__.py
-
4server/dev-run.sh
-
8server/documentation/api/authentication.rst
-
2server/documentation/api/index.rst
-
30server/documentation/api/user.rst
-
8server/documentation/conf.py
-
12server/documentation/introduction.rst
-
4server/entrypoint.sh
-
14server/manage.py
-
10server/run_tests.bat
-
12server/run_tests.sh
-
42server/server/__init__.py
-
4server/server/api/__init__.py
-
16server/server/api/authentication_api.py
-
2server/server/api/decorators.py
-
4server/server/api/health_api.py
-
2server/server/api/model.py
-
20server/server/api/user_api.py
-
0server/server/db.py
-
2server/server/default_settings.py
-
20server/server/errors.py
-
0server/server/middleware/__init__.py
-
8server/server/middleware/authentication_middleware.py
-
2server/server/model/__init__.py
-
4server/server/model/user_model.py
-
0server/server/service/__init__.py
-
6server/server/service/authentication_service.py
-
10server/server/service/patch_service.py
-
2server/server/service/role_service.py
-
4server/server/service/transformation_service.py
-
16server/server/service/user_service.py
-
8server/server/service/user_token_service.py
-
8server/server/service/validation_service.py
-
1server/server/utility/__init__.py
-
0server/server/utility/authentication_utility.py
-
8server/server/utility/json_utility.py
-
2server/server/utility/pagination_utility.py
-
0server/server/utility/session_utility.py
-
4server/setup.py
-
4server/tests/api/test_decorators.py
-
2server/tests/api/test_user_api.py
-
26server/tests/conftest.py
-
4server/tests/middleware/test_authentication_middleware.py
-
4server/tests/service/test_authentication_service.py
-
6server/tests/service/test_patch_service.py
-
2server/tests/service/test_role_service.py
-
8server/tests/service/test_transformation_service.py
-
4server/tests/service/test_validation_service.py
@ -1 +1 @@ |
|||
FLASK_APP=corvus:corvus |
|||
FLASK_APP=server:server |
@ -1,25 +1,25 @@ |
|||
FROM python:3.7-slim-stretch |
|||
MAINTAINER Drew Short <warrick@sothr.com> |
|||
|
|||
ENV CORVUS_APP_DIRECTORY /opt/corvus |
|||
ENV CORVUS_CONFIG_DIRECTORY /srv/corvus/config |
|||
ENV CORVUS_DATA_DIRECTORY /srv/corvus/data |
|||
ENV SERVER_APP_DIRECTORY /opt/server |
|||
ENV SERVER_CONFIG_DIRECTORY /srv/server/config |
|||
ENV SERVER_DATA_DIRECTORY /srv/server/data |
|||
|
|||
RUN mkdir -p ${CORVUS_APP_DIRECTORY} \ |
|||
&& mkdir -p ${CORVUS_CONFIG_DIRECTORY} \ |
|||
&& mkdir -p ${CORVUS_DATA_DIRECTORY} \ |
|||
RUN mkdir -p ${SERVER_APP_DIRECTORY} \ |
|||
&& mkdir -p ${SERVER_CONFIG_DIRECTORY} \ |
|||
&& mkdir -p ${SERVER_DATA_DIRECTORY} \ |
|||
&& pip install pipenv gunicorn |
|||
|
|||
VOLUME ${CORVUS_CONFIG_DIRECTORY} |
|||
VOLUME ${CORVUS_DATA_DIRECTORY} |
|||
VOLUME ${SERVER_CONFIG_DIRECTORY} |
|||
VOLUME ${SERVER_DATA_DIRECTORY} |
|||
|
|||
COPY ./ ${CORVUS_APP_DIRECTORY}/ |
|||
COPY ./ ${SERVER_APP_DIRECTORY}/ |
|||
|
|||
RUN cd ${CORVUS_APP_DIRECTORY} \ |
|||
RUN cd ${SERVER_APP_DIRECTORY} \ |
|||
&& pipenv install --system --deploy --ignore-pipfile |
|||
|
|||
EXPOSE 8080 |
|||
|
|||
WORKDIR ${CORVUS_APP_DIRECTORY} |
|||
WORKDIR ${SERVER_APP_DIRECTORY} |
|||
|
|||
CMD ./entrypoint.sh |
@ -1,4 +0,0 @@ |
|||
"""API blueprint exports.""" |
|||
from corvus.api.authentication_api import AUTH_BLUEPRINT |
|||
from corvus.api.user_api import USER_BLUEPRINT |
|||
from corvus.api.health_api import HEALTH_BLUEPRINT |
@ -1,2 +0,0 @@ |
|||
"""Expose models to be used in Corvus.""" |
|||
from corvus.model.user_model import User, UserToken |
@ -1 +0,0 @@ |
|||
"""Utilities for Corvus.""" |
@ -1,5 +1,5 @@ |
|||
#!/usr/bin/env bash |
|||
|
|||
FLASK_APP=corvus:corvus flask db upgrade |
|||
FLASK_APP=server:server flask db upgrade |
|||
python manage.py user register-admin |
|||
FLASK_APP=corvus:corvus flask run |
|||
FLASK_APP=server:server flask run |
@ -1,4 +1,14 @@ |
|||
Introduction To Corvus |
|||
======================== |
|||
|
|||
TODO |
|||
Corvus is the scaffolding for python web services. Among the things it offers are the following: |
|||
|
|||
* Management CLI for working with users |
|||
* Prebuilt auth framework with roles and tokens |
|||
* Hierarchical role models |
|||
* Stong testing foundation |
|||
* Strong code formatting testing foundation |
|||
* PipEnv scaffold for ensuring reproducable builds |
|||
* Prebuilt docker environments for runtime |
|||
* Pythonenv integration |
|||
* Lightweight Flask backend |
@ -1,10 +1,10 @@ |
|||
#!/usr/bin/env bash |
|||
|
|||
# Migrate the Database |
|||
FLASK_APP=corvus:corvus flask db upgrade |
|||
FLASK_APP=server:server flask db upgrade |
|||
|
|||
# Make sure an administrator is registered |
|||
python manage.py user register-admin |
|||
|
|||
# Start the application |
|||
gunicorn -b 0.0.0.0:8080 corvus:corvus |
|||
gunicorn -b 0.0.0.0:8080 server:server |
@ -0,0 +1,4 @@ |
|||
"""API blueprint exports.""" |
|||
from server.api.authentication_api import AUTH_BLUEPRINT |
|||
from server.api.user_api import USER_BLUEPRINT |
|||
from server.api.health_api import HEALTH_BLUEPRINT |
@ -1,19 +1,19 @@ |
|||
"""Authentication API blueprint and endpoint definitions.""" |
|||
from flask import Blueprint, g, abort, request |
|||
|
|||
from corvus.api.decorators import return_json |
|||
from corvus.api.model import APIMessage, APIResponse, APIPage |
|||
from corvus.middleware import authentication_middleware |
|||
from corvus.service import ( |
|||
from server.api.decorators import return_json |
|||
from server.api.model import APIMessage, APIResponse, APIPage |
|||
from server.middleware import authentication_middleware |
|||
from server.service import ( |
|||
user_token_service, |
|||
authentication_service, |
|||
user_service, |
|||
transformation_service |
|||
) |
|||
from corvus.middleware.authentication_middleware import Auth |
|||
from corvus.service.role_service import Role |
|||
from corvus.model import UserToken |
|||
from corvus.utility.pagination_utility import get_pagination_params |
|||
from server.middleware.authentication_middleware import Auth |
|||
from server.service.role_service import Role |
|||
from server.model import UserToken |
|||
from server.utility.pagination_utility import get_pagination_params |
|||
|
|||
AUTH_BLUEPRINT = Blueprint( |
|||
name='auth', import_name=__name__, url_prefix='/auth') |
@ -1,8 +1,8 @@ |
|||
"""Endpoint to expose the health of the application.""" |
|||
from flask import Blueprint |
|||
|
|||
from corvus.api.decorators import return_json |
|||
from corvus.api.model import APIResponse, APIMessage |
|||
from server.api.decorators import return_json |
|||
from server.api.model import APIResponse, APIMessage |
|||
|
|||
HEALTH_BLUEPRINT = Blueprint( |
|||
name='health', import_name=__name__, url_prefix='/health') |
@ -1,4 +1,4 @@ |
|||
"""Default settings for corvus.""" |
|||
"""Default settings for server.""" |
|||
|
|||
DEBUG = False |
|||
SECRET_KEY = b'\xb4\x89\x0f\x0f\xe5\x88\x97\xfe\x8d<\x0b@d\xe9\xa5\x87%' \ |
@ -0,0 +1,2 @@ |
|||
"""Expose models to be used.""" |
|||
from server.model.user_model import User, UserToken |
@ -1,8 +1,8 @@ |
|||
"""User related SQLALchemy models.""" |
|||
from sqlalchemy import Enum |
|||
|
|||
from corvus.db import db |
|||
from corvus.service.role_service import Role |
|||
from server.db import db |
|||
from server.service.role_service import Role |
|||
|
|||
|
|||
class User(db.Model): # pylint: disable=too-few-public-methods |
@ -1,11 +1,11 @@ |
|||
"""Patching support for db.Model objects.""" |
|||
from typing import Set, Optional, Any, Dict |
|||
|
|||
from corvus import errors |
|||
from corvus.db import db_model |
|||
from corvus.model import User |
|||
from corvus.service import transformation_service |
|||
from corvus.service import validation_service |
|||
from server import errors |
|||
from server.db import db_model |
|||
from server.model import User |
|||
from server.service import transformation_service |
|||
from server.service import validation_service |
|||
|
|||
|
|||
def get_patch_fields(patch_json: Dict[str, Any]) -> Set[str]: |
@ -1,4 +1,4 @@ |
|||
"""Role service for Corvus.""" |
|||
"""Role service.""" |
|||
from collections import defaultdict |
|||
from enum import Enum |
|||
from typing import Optional, List, Set, Dict |
@ -1,12 +1,12 @@ |
|||
"""Validation service for Corvus models.""" |
|||
"""Validation service for models.""" |
|||
|
|||
from typing import Type, Dict, Callable, Any, Set, Optional, Tuple |
|||
|
|||
from sqlalchemy import orm |
|||
|
|||
from corvus import errors |
|||
from corvus.db import db_model |
|||
from corvus.model import User |
|||
from server import errors |
|||
from server.db import db_model |
|||
from server.model import User |
|||
|
|||
_changable_attribute_names: Dict[str, Set[str]] = {} |
|||
|
@ -0,0 +1 @@ |
|||
"""Utilities.""" |
@ -1,8 +1,8 @@ |
|||
from setuptools import setup |
|||
|
|||
setup( |
|||
name='corvus', |
|||
packages=['corvus'], |
|||
name='server', |
|||
packages=['server'], |
|||
include_package_data=True, |
|||
install_requires=[ |
|||
'flask', |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue