skeleton done

This commit is contained in:
2020-11-27 03:52:17 +01:00
parent 7349e8e035
commit 28ee777ed1
20 changed files with 484 additions and 0 deletions

4
src/utils/__init__.py Normal file
View File

@@ -0,0 +1,4 @@
from .db import db
from .marshm import ma
from .healthchecks import health_database_status
from .security import security, user_datastore

27
src/utils/config.py Normal file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env python3
import os
"""
Configuration
"""
__author__ = "@tormakris"
__copyright__ = "Copyright 2020, Birbnetes Team"
__module_name__ = "config"
__version__text__ = "1"
PORT = os.environ.get("PORT", 8080)
DEBUG = os.environ.get("DEBUG", True)
SENTRY_DSN = os.environ.get("SENTRY_DSN")
RELEASE_ID = os.environ.get("RELEASE_ID", "test")
RELEASEMODE = os.environ.get("RELEASEMODE", "dev")
POSTGRES_HOSTNAME = os.getenv("POSTGRES_HOSTNAME", "localhost")
POSTGRES_USERNAME = os.getenv("POSTGRES_USERNAME", "webshop")
POSTGRES_PASSWORD = os.getenv("POSTGRES_PASSWORD", "webshop")
POSTGRES_DB = os.getenv("POSTGRES_DB", "webshop")
SECRET_KEY = os.getenv("SECRET_KEY")

13
src/utils/db.py Normal file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env python3
from flask_sqlalchemy import SQLAlchemy
"""
Databse object
"""
__author__ = '@tormakris'
__copyright__ = "Copyright 2020, UnstableVortex Team"
__module_name__ = "db"
__version__text__ = "1"
db = SQLAlchemy()

23
src/utils/healthchecks.py Normal file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env python3
from .db import db
"""
Healthchek functions
"""
__author__ = "@tormakris"
__copyright__ = "Copyright 2020, UnstableVortex Team"
__module_name__ = "healthchecks"
__version__text__ = "1"
def health_database_status():
is_database_working = True
output = 'database is ok'
try:
db.session.execute('SELECT 1')
except Exception as e:
output = str(e)
is_database_working = False
return is_database_working, output

14
src/utils/marshm.py Normal file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env python3
from flask_marshmallow import Marshmallow
"""
Marshmallow
"""
__author__ = '@tormakris'
__copyright__ = "Copyright 2020, UnstableVortex Team"
__module_name__ = "marshm"
__version__text__ = "1"
ma = Marshmallow()

18
src/utils/security.py Normal file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/env python3
"""
Flask-Security
"""
__author__ = '@tormakris'
__copyright__ = "Copyright 2020, UnstableVortex Team"
__module_name__ = "security"
__version__text__ = "1"
from flask_security import Security, SQLAlchemyUserDatastore
from models import User, Role
from utils import db
user_datastore = SQLAlchemyUserDatastore(db, User, Role)
security = Security()