Skip to content

Commit 41b004d

Browse files
authored
Merge pull request #13 from getmarkus/cm-branch-11
refactor: move repositories and use cases to core layer
2 parents 231ae4f + 460cfea commit 41b004d

File tree

22 files changed

+23
-29
lines changed

22 files changed

+23
-29
lines changed

config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class Settings(BaseSettings):
1717
env_smoke_test: str = ""
1818
project_name: str = ""
1919
database_url: str = "sqlite:///./issues.db"
20-
migrate_database: bool = True
20+
#database_url: str = "sqlite://"
21+
migrate_database: bool = False
2122
# BACKEND_CORS_ORIGINS is a JSON-formatted list of origins
2223
# e.g: '["http://localhost", "http://localhost:4200", "http://localhost:3000", \
2324
# "http://localhost:8080", "http://local.dockertoolbox.tiangolo.com"]'

main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import datetime
2-
import os
32
import uuid
43
from contextlib import asynccontextmanager
54
from typing import Annotated, Any, Dict, Optional
@@ -14,13 +13,12 @@
1413
from src.interface_adapters import api_router
1514
from src.interface_adapters.exceptions import AppException
1615
from src.interface_adapters.middleware.error_handler import app_exception_handler
16+
from src.resource_adapters.persistence.sqlmodel.database import get_engine
1717

1818
# https://brandur.org/logfmt
1919
# https://github.com/Delgan/loguru
2020
# https://betterstack.com/community/guides/logging/loguru/
2121

22-
env = os.getenv("PYTHON_TEMPLATE_ENV", ".env")
23-
2422
def isRunning() -> bool:
2523
#logger.info(f"App state: {dict(app.state.__dict__)}")
2624
running = getattr(app.state, "running", False)
@@ -31,6 +29,10 @@ def isRunning() -> bool:
3129
# https://fastapi.tiangolo.com/advanced/events/
3230
@asynccontextmanager
3331
async def lifespan(app: FastAPI):
32+
33+
# Initialize database if using SQLModel
34+
get_engine()
35+
3436
app.state.running = True
3537
logger.info("Lifespan started")
3638
logger.info(f"App state: {dict(app.state.__dict__)}")
File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from loguru import logger
44

5-
from src.app.ports.repositories.issues import IssueRepository
5+
from src.core.ports.repositories.issues import IssueRepository
66
from src.domain.issue import Issue
77
from src.interface_adapters.exceptions import NotFoundException
88

File renamed without changes.

src/interface_adapters/middleware/__init__.py renamed to src/domain/__init__.py

File renamed without changes.

0 commit comments

Comments
 (0)