feat(slice-4): VERSION file + versioned /healthz — the flotilla verify contract (§8.1)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+12
-2
@@ -11,6 +11,7 @@ from __future__ import annotations
|
||||
import logging
|
||||
import sys
|
||||
from contextlib import asynccontextmanager
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import psycopg
|
||||
@@ -26,6 +27,15 @@ from app.platform.mailer import Mailer
|
||||
from app.platform import session as session_mod
|
||||
|
||||
|
||||
# The repo-root VERSION file is the single version source: the deploy pin checks out its
|
||||
# tag, and /healthz must report it back (flotilla-core's verify gate compares them).
|
||||
_REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||
try:
|
||||
_APP_VERSION = (_REPO_ROOT / "VERSION").read_text().strip()
|
||||
except OSError:
|
||||
_APP_VERSION = "0.0.0"
|
||||
|
||||
|
||||
class RequestCodeBody(BaseModel):
|
||||
email: str
|
||||
|
||||
@@ -94,7 +104,7 @@ def create_app(database_url: str | None = None) -> FastAPI:
|
||||
finally:
|
||||
app.state.pool.close()
|
||||
|
||||
app = FastAPI(title="ecomm", version="0.3", lifespan=lifespan)
|
||||
app = FastAPI(title="ecomm", version=_APP_VERSION, lifespan=lifespan)
|
||||
|
||||
@app.get("/healthz")
|
||||
def healthz(response: Response, conn: psycopg.Connection = Depends(get_conn)):
|
||||
@@ -108,7 +118,7 @@ def create_app(database_url: str | None = None) -> FastAPI:
|
||||
if pending:
|
||||
response.status_code = 503
|
||||
return {"status": "unavailable", "reason": "migrations_pending"}
|
||||
return {"status": "ok"}
|
||||
return {"status": "ok", "version": _APP_VERSION}
|
||||
|
||||
@app.post("/api/auth/request-code")
|
||||
def request_code(
|
||||
|
||||
Reference in New Issue
Block a user