- Event ORM model with status/level enums, domain categories, review tracking - Alembic migration e7f3a9b1c5d0 for events table - Event crawler service with placeholder data (12 sample events) - GET /api/v1/events with status/domain/search filtering and overdue_days - EventArchivePage with filter toolbar (status, domain, search) and adaptive card grid - Status badges, level badges, domain tags, overdue markers on event cards - Loading/error/empty states, hover-to-honey card interaction Co-Authored-By: Claude <noreply@anthropic.com>
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
"""FastAPI 应用入口。"""
|
|
from contextlib import asynccontextmanager
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.database import engine, Base
|
|
from app.api import auth, users, audit, dashboard, gateway, health, cron, keys, kanban, events
|
|
from app.middleware.audit import AuditMiddleware
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
async with engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.create_all)
|
|
yield
|
|
await engine.dispose()
|
|
|
|
|
|
app = FastAPI(
|
|
title="Hive Manage v3",
|
|
version="0.1.0",
|
|
lifespan=lifespan,
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
app.add_middleware(AuditMiddleware)
|
|
|
|
app.include_router(auth.router)
|
|
app.include_router(users.router)
|
|
app.include_router(audit.router)
|
|
app.include_router(dashboard.router, prefix="/api/v1")
|
|
app.include_router(gateway.router, prefix="/api/v1")
|
|
app.include_router(health.router, prefix="/api/v1")
|
|
app.include_router(cron.router, prefix="/api/v1")
|
|
app.include_router(kanban.router, prefix="/api/v1")
|
|
app.include_router(events.router, prefix="/api/v1")
|
|
app.include_router(keys.router, prefix="/api/v1")
|
|
|
|
|
|
@app.get("/api/v1/health")
|
|
async def health_check():
|
|
return {"status": "ok"}
|