37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
import { NextResponse } from "next/server"
|
|
import { mcpCallTool, FLEET_BOARD_MCP_URL, cached } from "@/app/lib/fleet/fleetSource"
|
|
|
|
export const dynamic = "force-dynamic"
|
|
|
|
/**
|
|
* GET /api/fleet/kanban — VS-Liste + Kanban je VS (Kernfeature 3) als Proxy
|
|
* auf board-service-MCP (get_kanban / list_value_streams).
|
|
* Tower schreibt NIE direkt aufs Board-PVC (Single-Writer board-service).
|
|
* Cache 3 s (Karten-Statuswechsel erscheinen ohne Reload <=10 s, §8).
|
|
*/
|
|
export async function GET() {
|
|
try {
|
|
const data = await cached("fleet-kanban", 3000, async () => {
|
|
const vsList = await mcpCallTool(FLEET_BOARD_MCP_URL, "list_value_streams")
|
|
if (!vsList.ok) throw new Error(`list_value_streams: ${vsList.error}`)
|
|
const vsIds = ((vsList.data as { value_streams?: Array<{ vs_id: string }> }).value_streams || []).map(
|
|
(v) => v.vs_id
|
|
)
|
|
const boards = await Promise.all(
|
|
vsIds.map(async (vs) => {
|
|
const board = await mcpCallTool(FLEET_BOARD_MCP_URL, "get_kanban", { vs })
|
|
if (!board.ok) throw new Error(`get_kanban(${vs}): ${board.error}`)
|
|
return { vs, board: board.data }
|
|
})
|
|
)
|
|
return { value_streams: vsIds, boards, generated_at: new Date().toISOString() }
|
|
})
|
|
return NextResponse.json(data, { headers: { "Cache-Control": "no-store" } })
|
|
} catch (err) {
|
|
return NextResponse.json(
|
|
{ error: `FLEET_KANBAN_FAILED: ${err instanceof Error ? err.message : String(err)}` },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|