- app/api/deps.py: shared auth dependencies - app/api/routers/auth.py: login, me - app/api/routers/issues.py: CRUD, transition, assign, relations, tags, batch, search - app/api/routers/projects.py: CRUD, members, worklog summary - app/api/routers/users.py: CRUD, worklogs - app/api/routers/comments.py: CRUD - app/api/routers/webhooks.py: CRUD, logs, retry - app/api/routers/misc.py: API keys, activity, milestones, notifications, worklogs, export, dashboard - main.py: 1165 lines → 51 lines - Version bump to 0.2.0
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
"""HarborForge API — Agent/人类协同任务管理平台"""
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
app = FastAPI(
|
|
title="HarborForge API",
|
|
description="Agent/人类协同任务管理平台 API",
|
|
version="0.2.0"
|
|
)
|
|
|
|
# CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Health & version (kept at top level)
|
|
@app.get("/health", tags=["System"])
|
|
def health_check():
|
|
return {"status": "healthy"}
|
|
|
|
@app.get("/version", tags=["System"])
|
|
def version():
|
|
return {"name": "HarborForge", "version": "0.2.0", "description": "Agent/人类协同任务管理平台"}
|
|
|
|
# Register routers
|
|
from app.api.routers.auth import router as auth_router
|
|
from app.api.routers.issues import router as issues_router
|
|
from app.api.routers.projects import router as projects_router
|
|
from app.api.routers.users import router as users_router
|
|
from app.api.routers.comments import router as comments_router
|
|
from app.api.routers.webhooks import router as webhooks_router
|
|
from app.api.routers.misc import router as misc_router
|
|
|
|
app.include_router(auth_router)
|
|
app.include_router(issues_router)
|
|
app.include_router(projects_router)
|
|
app.include_router(users_router)
|
|
app.include_router(comments_router)
|
|
app.include_router(webhooks_router)
|
|
app.include_router(misc_router)
|
|
|
|
# Run database migration on startup
|
|
@app.on_event("startup")
|
|
def startup():
|
|
from app.core.config import Base, engine
|
|
from app.models import webhook, apikey, activity, milestone, notification, worklog
|
|
Base.metadata.create_all(bind=engine)
|