The backend no longer mentions MinIO anywhere: MinioClient -> GarageClient (minio_client.py -> garage_client.py), MINIO_* env vars -> GARAGE_*, and the `minio` Python package is replaced with `boto3` (AWS's generic S3 client) since Garage is the only storage backend this project targets now. S3 API semantics are unchanged, so document_service.py's behavior is identical — this is a naming and dependency swap, not a logic change. Also updates test fixtures/names (FakeMinioClient -> FakeGarageClient, FakeMinioSDK -> FakeS3SDK) and storage/README.md, which no longer frames Garage as a MinIO replacement (that migration note has served its purpose now that no MinIO reference remains in the codebase). Backend: 54/54 tests passing. Frontend: 38/38 tests passing (unaffected, verified for regressions since it talks to the backend only through the unchanged REST API).
40 lines
1.0 KiB
Python
40 lines
1.0 KiB
Python
import logging
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.config import settings
|
|
from app.dependencies import _get_garage_sdk
|
|
from app.routers import documents, search
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
app = FastAPI(title="DocHub API")
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.cors_origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(documents.router)
|
|
app.include_router(search.router)
|
|
|
|
|
|
@app.on_event("startup")
|
|
def ensure_bucket_exists():
|
|
try:
|
|
garage_sdk = _get_garage_sdk()
|
|
existing_buckets = {b["Name"] for b in garage_sdk.list_buckets().get("Buckets", [])}
|
|
if settings.garage_bucket not in existing_buckets:
|
|
garage_sdk.create_bucket(Bucket=settings.garage_bucket)
|
|
except Exception:
|
|
logger.warning("Could not verify/create Garage bucket '%s' on startup", settings.garage_bucket, exc_info=True)
|
|
|
|
|
|
@app.get("/health")
|
|
def health():
|
|
return {"status": "ok"}
|