- Add Cache-Control headers to admin GET endpoints (sections 60s, team 60s, bookings 30s, unread 15s, open-day 60s) - Validate Open Day date is not in the past on both create (POST) and update (PUT) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
37 lines
977 B
TypeScript
37 lines
977 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { getTeamMembers, createTeamMember } from "@/lib/db";
|
|
import { revalidatePath } from "next/cache";
|
|
import type { RichListItem, VictoryItem } from "@/types/content";
|
|
|
|
export async function GET() {
|
|
const members = getTeamMembers();
|
|
return NextResponse.json(members, {
|
|
headers: { "Cache-Control": "private, max-age=60" },
|
|
});
|
|
}
|
|
|
|
export async function POST(request: NextRequest) {
|
|
const data = await request.json() as {
|
|
name: string;
|
|
role: string;
|
|
image: string;
|
|
instagram?: string;
|
|
description?: string;
|
|
experience?: string[];
|
|
victories?: VictoryItem[];
|
|
education?: RichListItem[];
|
|
};
|
|
|
|
if (!data.name || !data.role || !data.image) {
|
|
return NextResponse.json(
|
|
{ error: "name, role, and image are required" },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
const id = createTeamMember(data);
|
|
revalidatePath("/");
|
|
|
|
return NextResponse.json({ id }, { status: 201 });
|
|
}
|