Stelle den Frontend-MVP und die v0.3-API auf develop bereit, damit Dev API und PWA zusammen deployen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
827e6a2a11
commit
b276758ee1
152 files changed
+25846
-34
No files matched your search
@@ -1 +0,0 @@
|
||||
__version__ = "0.1.0"
|
||||
@@ -1,45 +0,0 @@
|
||||
from fastapi import APIRouter
|
||||
from fastapi.responses import JSONResponse
|
||||
from sqlalchemy import text
|
||||
|
||||
from alembic.config import Config
|
||||
from alembic.runtime.migration import MigrationContext
|
||||
from alembic.script import ScriptDirectory
|
||||
|
||||
from app.persistence.db import engine
|
||||
from app.settings import get_settings
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
def _alembic_at_head() -> bool:
|
||||
config = Config("alembic.ini")
|
||||
script = ScriptDirectory.from_config(config)
|
||||
with engine.connect() as connection:
|
||||
context = MigrationContext.configure(connection)
|
||||
return set(context.get_current_heads()) == set(script.get_heads())
|
||||
|
||||
|
||||
@router.get("/health/live")
|
||||
def live() -> dict[str, str]:
|
||||
return {"status": "ok"}
|
||||
|
||||
|
||||
@router.get("/health/ready", response_model=None)
|
||||
def ready() -> JSONResponse | dict[str, str]:
|
||||
settings = get_settings()
|
||||
try:
|
||||
with engine.connect() as connection:
|
||||
connection.execute(text("SELECT 1"))
|
||||
if not _alembic_at_head():
|
||||
return JSONResponse(
|
||||
{"status": "not_ready", "reason": "migration_behind_head"},
|
||||
status_code=503,
|
||||
)
|
||||
except Exception:
|
||||
return JSONResponse({"status": "not_ready", "reason": "database"}, status_code=503)
|
||||
return {
|
||||
"status": "ready",
|
||||
"environment": settings.environment,
|
||||
"engine_build": settings.engine_build,
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
from app.api.health import router as health_router
|
||||
|
||||
app = FastAPI(
|
||||
title="Buying Agent",
|
||||
version="0.1.0",
|
||||
description="Walking skeleton for the buying and deal evaluation API.",
|
||||
)
|
||||
app.include_router(health_router)
|
||||
@@ -1,18 +0,0 @@
|
||||
from collections.abc import Generator
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import Session, sessionmaker
|
||||
|
||||
from app.settings import get_settings
|
||||
|
||||
settings = get_settings()
|
||||
engine = create_engine(settings.database_url, pool_pre_ping=True)
|
||||
SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False)
|
||||
|
||||
|
||||
def get_session() -> Generator[Session, None, None]:
|
||||
session = SessionLocal()
|
||||
try:
|
||||
yield session
|
||||
finally:
|
||||
session.close()
|
||||
@@ -1,27 +0,0 @@
|
||||
from functools import lru_cache
|
||||
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
|
||||
|
||||
db_host: str = "postgres"
|
||||
db_port: int = 5432
|
||||
db_name: str = "buyingagent"
|
||||
db_user: str = "buyingagent"
|
||||
db_password: str = "change_me"
|
||||
environment: str = "development"
|
||||
engine_build: str = "dev"
|
||||
|
||||
@property
|
||||
def database_url(self) -> str:
|
||||
return (
|
||||
f"postgresql+psycopg://{self.db_user}:{self.db_password}"
|
||||
f"@{self.db_host}:{self.db_port}/{self.db_name}"
|
||||
)
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_settings() -> Settings:
|
||||
return Settings()
|
||||
Reference in new issue
Block a user