M1: implement operational core
Demo auth, seed import/reset, dashboard, vehicle/booking list+detail, audit trail. Backend: 19 tests passing, ruff clean. Frontend: React Router shell, typed API client, responsive pages. Verified end-to-end via curl and browser.
This commit is contained in:
+44
-3
@@ -1,9 +1,44 @@
|
||||
from fastapi import FastAPI
|
||||
import uuid
|
||||
|
||||
from fastapi import FastAPI, HTTPException, Request
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from app.api.routers import audit, bookings, dashboard, demo, vehicles
|
||||
from app.core.config import get_settings
|
||||
from app.core.errors import AppError, error_body
|
||||
|
||||
settings = get_settings()
|
||||
app = FastAPI(title="MobilityOps API", version="0.0.1")
|
||||
app = FastAPI(title="MobilityOps API", version="0.1.0")
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=[o.strip() for o in settings.cors_allow_origins.split(",")],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
|
||||
@app.exception_handler(AppError)
|
||||
def handle_app_error(_request: Request, exc: AppError) -> JSONResponse:
|
||||
return JSONResponse(
|
||||
status_code=exc.status_code,
|
||||
content=error_body(exc.code, exc.message, exc.correlation_id, exc.details),
|
||||
)
|
||||
|
||||
|
||||
@app.exception_handler(HTTPException)
|
||||
def handle_http_exception(_request: Request, exc: HTTPException) -> JSONResponse:
|
||||
return JSONResponse(
|
||||
status_code=exc.status_code,
|
||||
content=error_body(
|
||||
code=str(exc.status_code),
|
||||
message=str(exc.detail),
|
||||
correlation_id=str(uuid.uuid4()),
|
||||
details={},
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
@@ -18,5 +53,11 @@ def system_status() -> dict[str, object]:
|
||||
"environment": settings.mobilityops_env,
|
||||
"demo_mode": settings.mobilityops_demo_mode,
|
||||
"knowledge_provider": settings.knowledge_provider,
|
||||
"scaffold": True,
|
||||
}
|
||||
|
||||
|
||||
app.include_router(demo.router)
|
||||
app.include_router(dashboard.router)
|
||||
app.include_router(vehicles.router)
|
||||
app.include_router(bookings.router)
|
||||
app.include_router(audit.router)
|
||||
|
||||
Reference in New Issue
Block a user