30 lines
818 B
TypeScript
30 lines
818 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { fetchGanttApi } from "@/lib/data/gantt-api";
|
|
|
|
interface ActivityPayload {
|
|
tasks?: unknown[];
|
|
projects?: unknown[];
|
|
}
|
|
|
|
export async function GET() {
|
|
try {
|
|
const payload = await fetchGanttApi<ActivityPayload>("/tasks?scope=all");
|
|
|
|
return NextResponse.json(
|
|
{
|
|
tasks: Array.isArray(payload.tasks) ? payload.tasks : [],
|
|
projects: Array.isArray(payload.projects) ? payload.projects : [],
|
|
},
|
|
{
|
|
headers: {
|
|
"Cache-Control": "no-store",
|
|
},
|
|
}
|
|
);
|
|
} catch (error) {
|
|
const message = error instanceof Error ? error.message : "Failed to fetch activity data";
|
|
console.error("[api/activity] Request failed", error);
|
|
return NextResponse.json({ error: message }, { status: 500 });
|
|
}
|
|
}
|