feat(sandbox): add Node.js code execution support to sandbox
This commit is contained in:
@@ -9,4 +9,4 @@ router = APIRouter()
|
||||
@router.get("/health", response_model=HealthResponse)
|
||||
async def health_check():
|
||||
"""Health check endpoint"""
|
||||
return HealthResponse(status="healthy", version="2.0.0")
|
||||
return HealthResponse(status="healthy", version="0.1.0")
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from app.middleware.auth import verify_api_key
|
||||
from app.middleware.concurrency import check_max_requests, acquire_worker
|
||||
from app.middleware.concurrency import concurrency_guard
|
||||
|
||||
from app.models import (
|
||||
RunCodeRequest,
|
||||
ApiResponse,
|
||||
UpdateDependencyRequest,
|
||||
error_response
|
||||
)
|
||||
from app.services.nodejs_service import run_nodejs_code
|
||||
from app.services.python_service import (
|
||||
run_python_code,
|
||||
list_python_dependencies,
|
||||
@@ -25,16 +27,14 @@ router = APIRouter(
|
||||
@router.post(
|
||||
"/run",
|
||||
response_model=ApiResponse,
|
||||
dependencies=[Depends(check_max_requests),
|
||||
Depends(acquire_worker)]
|
||||
dependencies=[Depends(concurrency_guard)]
|
||||
)
|
||||
async def run_code(request: RunCodeRequest):
|
||||
"""Execute code in sandbox"""
|
||||
if request.language == "python3":
|
||||
return await run_python_code(request.code, request.preload, request.options)
|
||||
elif request.language == "nodejs":
|
||||
# TODO
|
||||
return error_response(-400, "TODO")
|
||||
return await run_nodejs_code(request.code, request.preload, request.options)
|
||||
else:
|
||||
return error_response(-400, "unsupported language")
|
||||
|
||||
@@ -55,5 +55,3 @@ async def update_dependencies(request: UpdateDependencyRequest):
|
||||
return await update_python_dependencies()
|
||||
else:
|
||||
return error_response(-400, "unsupported language")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user