mirror of
https://github.com/blackboxprogramming/BlackRoad-Operating-System.git
synced 2026-03-17 00:57:12 -05:00
Merge branch origin/codex/implement-unified-status-page-for-apis-8w9cw1 into main
This commit is contained in:
@@ -36,6 +36,11 @@ class Settings(BaseSettings):
|
||||
def allowed_origins_list(self) -> List[str]:
|
||||
return [origin.strip() for origin in self.ALLOWED_ORIGINS.split(",")]
|
||||
|
||||
# Prism / Status page targets
|
||||
PRISM_CORE_API_URL: str = ""
|
||||
PRISM_PUBLIC_API_URL: str = ""
|
||||
PRISM_CONSOLE_URL: str = ""
|
||||
|
||||
# AWS S3
|
||||
AWS_ACCESS_KEY_ID: str = ""
|
||||
AWS_SECRET_ACCESS_KEY: str = ""
|
||||
|
||||
@@ -5,6 +5,7 @@ from fastapi.responses import JSONResponse, FileResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from contextlib import asynccontextmanager
|
||||
import time
|
||||
from datetime import datetime, timezone
|
||||
import os
|
||||
|
||||
from app.config import settings
|
||||
@@ -229,8 +230,22 @@ else:
|
||||
async def health_check():
|
||||
"""Health check endpoint"""
|
||||
return {
|
||||
"service": "core-api",
|
||||
"status": "healthy",
|
||||
"timestamp": time.time()
|
||||
"environment": settings.ENVIRONMENT,
|
||||
"version": settings.APP_VERSION,
|
||||
"timestamp": datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
|
||||
|
||||
@app.get("/version")
|
||||
async def version():
|
||||
"""Service version endpoint"""
|
||||
return {
|
||||
"service": "core-api",
|
||||
"version": settings.APP_VERSION,
|
||||
"environment": settings.ENVIRONMENT,
|
||||
"timestamp": datetime.now(timezone.utc).isoformat(),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -64,6 +64,15 @@ async def serve_prism_console():
|
||||
return FileResponse(prism_index)
|
||||
|
||||
|
||||
@router.get("/prism/health")
|
||||
async def prism_health():
|
||||
"""Health endpoint for Prism Console assets."""
|
||||
return {
|
||||
"service": "prism-console",
|
||||
"status": "healthy",
|
||||
}
|
||||
|
||||
|
||||
@router.get("/prism/{file_path:path}")
|
||||
async def serve_prism_static_files(file_path: str):
|
||||
"""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""System endpoints for core OS operations"""
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi import APIRouter, Depends, Request
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
import os
|
||||
|
||||
from app.config import settings
|
||||
@@ -22,7 +22,7 @@ async def get_version():
|
||||
|
||||
return {
|
||||
"version": settings.APP_VERSION,
|
||||
"build_time": datetime.utcnow().isoformat(),
|
||||
"build_time": datetime.now(timezone.utc).isoformat(),
|
||||
"env": settings.ENVIRONMENT,
|
||||
"git_sha": git_sha[:8] if len(git_sha) > 8 else git_sha,
|
||||
"app_name": settings.APP_NAME,
|
||||
@@ -81,3 +81,39 @@ async def get_os_state(db: AsyncSession = Depends(get_db)):
|
||||
},
|
||||
"note": "This is a stub endpoint. Full OS state tracking coming in Phase 2.",
|
||||
}
|
||||
|
||||
|
||||
@router.get("/prism/config")
|
||||
async def prism_config(request: Request):
|
||||
"""Return Prism Console service configuration for health/status checks."""
|
||||
|
||||
def resolve_url(env_url: str, fallback: str) -> str:
|
||||
return env_url.rstrip("/") if env_url else fallback.rstrip("/")
|
||||
|
||||
base_url = str(request.base_url).rstrip("/")
|
||||
|
||||
services = [
|
||||
{
|
||||
"name": "core-api",
|
||||
"url": resolve_url(settings.PRISM_CORE_API_URL, base_url),
|
||||
"health_path": "/health",
|
||||
"version_path": "/version",
|
||||
},
|
||||
{
|
||||
"name": "public-api",
|
||||
"url": resolve_url(settings.PRISM_PUBLIC_API_URL, base_url),
|
||||
"health_path": "/health",
|
||||
"version_path": "/version",
|
||||
},
|
||||
{
|
||||
"name": "prism-console",
|
||||
"url": resolve_url(settings.PRISM_CONSOLE_URL, base_url),
|
||||
"health_path": "/prism/health",
|
||||
"version_path": "/version",
|
||||
},
|
||||
]
|
||||
|
||||
return {
|
||||
"environment": settings.ENVIRONMENT,
|
||||
"services": services,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user