From 5ae18553b5e7863261ed64a52ef1653ce3279614 Mon Sep 17 00:00:00 2001 From: Hemang Date: Tue, 4 Feb 2025 15:51:07 +0100 Subject: [PATCH 1/3] Add .gitignore --- .gitignore | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..da00cf7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +# Python cache and test artifacts +__pycache__/ +.pytest_cache/ +.py[oc] + +# Coverage and build artifacts +.coverage +htmlcov/ +build/ +dist/ +wheels/ +*.egg-info + +# Virtual environment +.venv/ \ No newline at end of file From c1f6eb2ef353c81cc2d84ac409df79882de68290 Mon Sep 17 00:00:00 2001 From: Hemang Date: Tue, 4 Feb 2025 16:14:57 +0100 Subject: [PATCH 2/3] Add route for auto-generated docs. --- proxy/serve.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/proxy/serve.py b/proxy/serve.py index b665c55..a0216c3 100644 --- a/proxy/serve.py +++ b/proxy/serve.py @@ -6,7 +6,11 @@ from routes.anthropic import proxy as anthropic_proxy from routes.open_ai import proxy as open_ai_proxy from starlette_compress import CompressMiddleware -app = fastapi.FastAPI() +app = fastapi.app = fastapi.FastAPI( + docs_url="/api/v1/proxy/docs", + redoc_url="/api/v1/proxy/redoc", + openapi_url="/api/v1/proxy/openapi.json", +) app.add_middleware(CompressMiddleware) router = fastapi.APIRouter(prefix="/api/v1") From 8ce36c2579ef605dddd48b5255a9406e546d9fa4 Mon Sep 17 00:00:00 2001 From: Hemang Date: Tue, 4 Feb 2025 16:15:23 +0100 Subject: [PATCH 3/3] Add a run.sh with build, up, down and logs. --- run.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 run.sh diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..1f50d77 --- /dev/null +++ b/run.sh @@ -0,0 +1,39 @@ +up() { + # Ensure the main network exists + docker network inspect invariant-explorer-web >/dev/null 2>&1 || \ + docker network create invariant-explorer-web + + # Start your local docker-compose services + docker compose -f docker-compose.local.yml up -d + + echo "Proxy started at http://localhost/api/v1/proxy/" + echo "See http://localhost/api/v1/proxy/docs for API documentation" +} + +build() { + # Build local services + docker compose -f docker-compose.local.yml build +} + +down() { + # Bring down local services + docker compose -f docker-compose.local.yml down +} + +# ----------------------------- +# Command dispatcher +# ----------------------------- +case "$1" in + "up") + up + ;; + "build") + build + ;; + "down") + down + ;; + "logs") + docker compose -f docker-compose.local.yml logs -f + ;; +esac \ No newline at end of file