feat(services): add authenticated services listing
This commit is contained in:
@@ -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
|
||||||
+6
-4
@@ -7,6 +7,7 @@ from fastapi import FastAPI
|
|||||||
|
|
||||||
from api.auth.router import router as auth_router
|
from api.auth.router import router as auth_router
|
||||||
from api.proxy.router import router as proxy_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.config import settings
|
||||||
from core.mongodb import close_mongodb, init_mongodb
|
from core.mongodb import close_mongodb, init_mongodb
|
||||||
from core.redis import close_redis, init_redis
|
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 []
|
app.state.services = get_all_services(home_dir) or []
|
||||||
if not app.state.services:
|
if not app.state.services:
|
||||||
warning = (
|
warning = (
|
||||||
"\n" + "!" * 60 + "\n"
|
"\n" + "!" * 60 + "\n"
|
||||||
" WARNING: No services found in home directory!\n"
|
" WARNING: No services found in home directory!\n"
|
||||||
f" Scanned: {home_dir}\n"
|
f" Scanned: {home_dir}\n"
|
||||||
+ "!" * 60 + "\n"
|
+ "!" * 60 + "\n"
|
||||||
)
|
)
|
||||||
print(warning, file=sys.stderr)
|
print(warning, file=sys.stderr)
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ app = FastAPI(
|
|||||||
|
|
||||||
app.include_router(auth_router)
|
app.include_router(auth_router)
|
||||||
app.include_router(proxy_router)
|
app.include_router(proxy_router)
|
||||||
|
app.include_router(services_router)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
|
|||||||
Reference in New Issue
Block a user