diff --git a/app/api/services/__init__.py b/app/api/services/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/api/services/router.py b/app/api/services/router.py new file mode 100644 index 0000000..40b93dc --- /dev/null +++ b/app/api/services/router.py @@ -0,0 +1,14 @@ +from fastapi import APIRouter, Depends, Request + +from core.security import require_authenticated_user + +router = APIRouter( + prefix="/services", + tags=["Services"], + dependencies=[Depends(require_authenticated_user)], +) + + +@router.get("") +async def get_services(request: Request): + return request.app.state.services diff --git a/app/main.py b/app/main.py index fe1ef19..f7cb55c 100644 --- a/app/main.py +++ b/app/main.py @@ -7,6 +7,7 @@ from fastapi import FastAPI from api.auth.router import router as auth_router from api.proxy.router import router as proxy_router +from api.services.router import router as services_router from core.config import settings from core.mongodb import close_mongodb, init_mongodb from core.redis import close_redis, init_redis @@ -31,10 +32,10 @@ async def lifespan(_: FastAPI): app.state.services = get_all_services(home_dir) or [] if not app.state.services: warning = ( - "\n" + "!" * 60 + "\n" - " WARNING: No services found in home directory!\n" - f" Scanned: {home_dir}\n" - + "!" * 60 + "\n" + "\n" + "!" * 60 + "\n" + " WARNING: No services found in home directory!\n" + f" Scanned: {home_dir}\n" + + "!" * 60 + "\n" ) print(warning, file=sys.stderr) @@ -57,6 +58,7 @@ app = FastAPI( app.include_router(auth_router) app.include_router(proxy_router) +app.include_router(services_router) @app.get("/")