Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket # 45: creating a new branch #54

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion db_revisions/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ENV = os.getenv("ENV", "LOCAL")

if ENV == "LOCAL":
load_dotenv("src/.env.local")
file_dir = os.path.dirname(os.path.realpath(__file__))
load_dotenv(f"{file_dir}/../src/.env.local")
else:
load_dotenv()

Expand Down
12 changes: 12 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import os
import logging
from http import HTTPStatus
from fastapi import FastAPI, HTTPException, Request
from fastapi.responses import JSONResponse
from fastapi.security import OAuth2AuthorizationCodeBearer
from fastapi.middleware.cors import CORSMiddleware
from starlette.middleware.authentication import AuthenticationMiddleware
from alembic.config import Config
from alembic import command

from routers import admin_router, institutions_router

Expand All @@ -17,6 +20,15 @@
app = FastAPI()


@app.on_event("startup")
async def app_start():
file_dir = os.path.dirname(os.path.realpath(__file__))
alembic_cfg = Config(f"{file_dir}/../alembic.ini")
alembic_cfg.set_main_option("script_location", f"{file_dir}/../db_revisions")
alembic_cfg.set_main_option("prepend_sys_path", f"{file_dir}/../")
command.upgrade(alembic_cfg, "head")


@app.exception_handler(HTTPException)
async def http_exception_handler(request: Request, exception: HTTPException) -> JSONResponse:
log.error(exception, exc_info=True, stack_info=True)
Expand Down
Loading