2024-06-22 10:30:51 +02:00
|
|
|
import { NextResponse } from "next/server";
|
|
|
|
import clientPromise from "@/lib/db";
|
2024-09-07 20:56:08 +02:00
|
|
|
import { revalidatePath } from "next/cache";
|
2024-06-22 10:30:51 +02:00
|
|
|
|
2024-06-22 11:57:32 +02:00
|
|
|
// Force the API to use SSR instead of static generation
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
|
2024-06-22 10:30:51 +02:00
|
|
|
export async function POST(request: Request) {
|
2024-09-07 09:12:48 +02:00
|
|
|
const body = await request.json();
|
|
|
|
const { version, date, bullets } = body;
|
2024-06-22 10:30:51 +02:00
|
|
|
|
2024-09-07 09:12:48 +02:00
|
|
|
const client = await clientPromise;
|
2024-09-07 21:11:11 +02:00
|
|
|
const db = client.db(process.env.MONGODB_DB);
|
2024-06-22 10:30:51 +02:00
|
|
|
|
2024-09-07 09:12:48 +02:00
|
|
|
const result = await db.collection("logs").insertOne({
|
|
|
|
version,
|
|
|
|
date,
|
|
|
|
bullets
|
|
|
|
});
|
2024-06-22 10:30:51 +02:00
|
|
|
|
2024-09-07 20:56:08 +02:00
|
|
|
revalidatePath("/changelog");
|
|
|
|
|
2024-09-07 09:12:48 +02:00
|
|
|
return NextResponse.json({ success: true, id: result.insertedId });
|
2024-06-22 10:30:51 +02:00
|
|
|
}
|