27 lines
971 B
TypeScript
27 lines
971 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { requireRequestSession } from "@/lib/boss-auth";
|
|
import { listDispatchPlansByProject, readState } from "@/lib/boss-data";
|
|
|
|
export async function GET(
|
|
request: NextRequest,
|
|
context: { params: Promise<{ projectId: string }> },
|
|
) {
|
|
const session = await requireRequestSession(request);
|
|
if (!session) {
|
|
return NextResponse.json({ ok: false, message: "UNAUTHORIZED" }, { status: 401 });
|
|
}
|
|
|
|
const { projectId } = await context.params;
|
|
const state = await readState();
|
|
const project = state.projects.find((item) => item.id === projectId);
|
|
if (!project) {
|
|
return NextResponse.json({ ok: false, message: "PROJECT_NOT_FOUND" }, { status: 404 });
|
|
}
|
|
if (!project.isGroup) {
|
|
return NextResponse.json({ ok: false, message: "PROJECT_NOT_GROUP_CHAT" }, { status: 400 });
|
|
}
|
|
|
|
const plans = await listDispatchPlansByProject(projectId);
|
|
return NextResponse.json({ ok: true, plans });
|
|
}
|