Skip to content

Commit

Permalink
Ez Andy Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
WillNilges committed Sep 3, 2023
1 parent f3f813a commit 5f0324f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
5 changes: 2 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
retries: 3
start_period: 5s
volumes:
- postgres-storage:/var/lib/postgresql/data/
- postgres_data:/var/lib/postgresql/data/

meshdb:
depends_on:
Expand All @@ -35,10 +35,9 @@ services:
DB_USER: ${DB_USER}
DB_HOST: ${DB_HOST}
DB_PASSWORD: ${DB_PASSWORD}
#entrypoint: "gunicorn wsgi:app --graceful-timeout 5 --bind=0.0.0.0:8080"

volumes:
postgres-storage:
postgres_data:

networks:
api:
12 changes: 7 additions & 5 deletions meshdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ def create_app():
app.config["SECURITY_PASSWORD_SALT"] = os.environ.get("SECURITY_PASSWORD_SALT")
app.config["REMEMBER_COOKIE_SAMESITE"] = "strict"
app.config["SESSION_COOKIE_SAMESITE"] = "strict"
app.config["SQLALCHEMY_DATABASE_URI"] = f"postgresql://{os.getenv('DB_USER')}:{os.getenv('DB_PASSWORD')}@{os.getenv('DB_HOST')}/{os.getenv('DB_NAME')}"
app.config[
"SQLALCHEMY_DATABASE_URI"
] = f"postgresql://{os.getenv('DB_USER')}:{os.getenv('DB_PASSWORD')}@{os.getenv('DB_HOST')}/{os.getenv('DB_NAME')}"

# csrf breaks token auth, need to investigate further
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
app.config["WTF_CSRF_ENABLED"] = False

# Configure Database
from meshdb.db.setup import setup_db
setup_db()
from meshdb.db.setup import initialize_db

initialize_db()

db.init_app(app)

Expand All @@ -48,9 +51,8 @@ def create_app():
app.security.datastore.create_user(email="[email protected]", password=hash_password("abcd1234"))
db.session.commit()

from .views import route_blueprint
from .routes import route_blueprint

app.register_blueprint(route_blueprint)


return app
4 changes: 2 additions & 2 deletions meshdb/db/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from ..db.database import create_db_engine


def setup_db():
engine = create_db_engine() # TODO: Delete?
def initialize_db():
engine = create_db_engine() # TODO: Delete?

if not database_exists(engine.url):
print("Database not found. Bootstrapping....")
Expand Down
File renamed without changes.

0 comments on commit 5f0324f

Please sign in to comment.