wip: snapshot full local workspace state
Some checks are pending
Build and Push Docker Images / changes (push) Waiting to run
Build and Push Docker Images / build-backend (push) Blocked by required conditions
Build and Push Docker Images / build-frontend (push) Blocked by required conditions
Build and Push Docker Images / build-admin-frontend (push) Blocked by required conditions
Some checks are pending
Build and Push Docker Images / changes (push) Waiting to run
Build and Push Docker Images / build-backend (push) Blocked by required conditions
Build and Push Docker Images / build-frontend (push) Blocked by required conditions
Build and Push Docker Images / build-admin-frontend (push) Blocked by required conditions
This commit is contained in:
@@ -1,61 +1,61 @@
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.api import admin_providers, admin_reload
|
||||
from app.core.config import settings
|
||||
from app.core.logging import get_logger, setup_logging
|
||||
from app.db.database import init_db
|
||||
|
||||
setup_logging()
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
"""Admin App lifespan manager."""
|
||||
logger.info("admin_app_starting")
|
||||
await init_db()
|
||||
|
||||
# 可以在这里加载特定的 Admin 缓存或预热
|
||||
|
||||
yield
|
||||
logger.info("admin_app_shutdown")
|
||||
|
||||
|
||||
app = FastAPI(
|
||||
title=f"{settings.app_name} Admin Console",
|
||||
description="Administrative Control Plane for DreamWeaver.",
|
||||
version="0.1.0",
|
||||
lifespan=lifespan,
|
||||
)
|
||||
|
||||
# Admin 后台通常允许更宽松的 CORS,或者特定的管理域名
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=settings.cors_origins, # 或者专门的 ADMIN_CORS_ORIGINS
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# 根据配置开关挂载路由
|
||||
if settings.enable_admin_console:
|
||||
app.include_router(admin_providers.router, prefix="/admin", tags=["admin-providers"])
|
||||
app.include_router(admin_reload.router, prefix="/admin", tags=["admin-reload"])
|
||||
else:
|
||||
@app.get("/admin/{path:path}")
|
||||
@app.post("/admin/{path:path}")
|
||||
@app.put("/admin/{path:path}")
|
||||
@app.delete("/admin/{path:path}")
|
||||
async def admin_disabled(path: str):
|
||||
from fastapi import HTTPException
|
||||
raise HTTPException(
|
||||
status_code=403,
|
||||
detail="Admin console is disabled in environment configuration."
|
||||
)
|
||||
|
||||
@app.get("/health")
|
||||
async def health_check():
|
||||
return {"status": "ok", "service": "admin-backend"}
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.api import admin_providers, admin_reload
|
||||
from app.core.config import settings
|
||||
from app.core.logging import get_logger, setup_logging
|
||||
from app.db.database import init_db
|
||||
|
||||
setup_logging()
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
"""Admin App lifespan manager."""
|
||||
logger.info("admin_app_starting")
|
||||
await init_db()
|
||||
|
||||
# 可以在这里加载特定的 Admin 缓存或预热
|
||||
|
||||
yield
|
||||
logger.info("admin_app_shutdown")
|
||||
|
||||
|
||||
app = FastAPI(
|
||||
title=f"{settings.app_name} Admin Console",
|
||||
description="Administrative Control Plane for DreamWeaver.",
|
||||
version="0.1.0",
|
||||
lifespan=lifespan,
|
||||
)
|
||||
|
||||
# Admin 后台通常允许更宽松的 CORS,或者特定的管理域名
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=settings.cors_origins, # 或者专门的 ADMIN_CORS_ORIGINS
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# 根据配置开关挂载路由
|
||||
if settings.enable_admin_console:
|
||||
app.include_router(admin_providers.router, prefix="/admin", tags=["admin-providers"])
|
||||
app.include_router(admin_reload.router, prefix="/admin", tags=["admin-reload"])
|
||||
else:
|
||||
@app.get("/admin/{path:path}")
|
||||
@app.post("/admin/{path:path}")
|
||||
@app.put("/admin/{path:path}")
|
||||
@app.delete("/admin/{path:path}")
|
||||
async def admin_disabled(path: str):
|
||||
from fastapi import HTTPException
|
||||
raise HTTPException(
|
||||
status_code=403,
|
||||
detail="Admin console is disabled in environment configuration."
|
||||
)
|
||||
|
||||
@app.get("/health")
|
||||
async def health_check():
|
||||
return {"status": "ok", "service": "admin-backend"}
|
||||
|
||||
Reference in New Issue
Block a user