From: Michael Tremer Date: Fri, 20 Jun 2025 09:28:06 +0000 (+0000) Subject: API: Add an /api/v1 prefix to everything X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb302bb2dca69692d86760b61e6bb3ae238d0920;p=pbs.git API: Add an /api/v1 prefix to everything Signed-off-by: Michael Tremer --- diff --git a/src/api/__init__.py b/src/api/__init__.py index 7fab99e6..b7480eed 100644 --- a/src/api/__init__.py +++ b/src/api/__init__.py @@ -45,7 +45,15 @@ app.add_middleware( allow_headers=["*"], ) +# Create a router for APIv1 +apiv1 = fastapi.APIRouter( + prefix="/api/v1", +) + # Load all further modules from . import auth from . import builds from . import uploads + +# Add the APIv1 to the app +app.include_router(apiv1) diff --git a/src/api/auth.py b/src/api/auth.py index 7360be63..0a198277 100644 --- a/src/api/auth.py +++ b/src/api/auth.py @@ -26,7 +26,7 @@ import os import pydantic import socket -from . import app +from . import apiv1 from . import backend from .. import users @@ -186,4 +186,4 @@ async def auth_refresh(data: RefreshRequest): return AuthResponse(access_token=access_token, refresh_token=data.refresh_token) # Add everything to the app -app.include_router(router) +apiv1.include_router(router) diff --git a/src/api/builds.py b/src/api/builds.py index dc05e028..21057aac 100644 --- a/src/api/builds.py +++ b/src/api/builds.py @@ -21,12 +21,12 @@ import fastapi import uuid -from . import app +from . import apiv1 from . import backend from .. import builds -@app.get("/builds/{build_id}") +@apiv1.get("/builds/{build_id}") async def get(build_id: uuid.UUID) -> builds.Build: build = await backend.builds.get_by_uuid(build_id) diff --git a/src/api/uploads.py b/src/api/uploads.py index 8881738b..797be84f 100644 --- a/src/api/uploads.py +++ b/src/api/uploads.py @@ -22,7 +22,7 @@ import fastapi import pydantic import uuid -from . import app +from . import apiv1 from . import auth from . import backend @@ -130,5 +130,5 @@ async def delete(upload: uploads.Upload = fastapi.Depends(get_upload)): # Send 204 return fastapi.Response(status_code=204) -# Add everything to the app -app.include_router(router) +# Add everything to the APIv1 +apiv1.include_router(router)