2024-07-30 21:34:39 +02:00
|
|
|
import { NextRequest, NextResponse } from "next/server";
|
|
|
|
import clientPromise from "@/lib/db";
|
|
|
|
|
|
|
|
// Force the API to use SSR instead of static generation
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
|
|
|
|
// Handler for GET requests
|
|
|
|
export async function GET(req: NextRequest) {
|
2024-09-07 09:12:48 +02:00
|
|
|
try {
|
|
|
|
const client = await clientPromise;
|
2024-09-07 21:11:11 +02:00
|
|
|
const db = client.db(process.env.MONGODB_DB);
|
2024-09-07 09:12:48 +02:00
|
|
|
const downloads = await db.collection("vulnerabilities").find().toArray();
|
|
|
|
return NextResponse.json(downloads, { status: 200 });
|
|
|
|
} catch (error) {
|
|
|
|
return NextResponse.json(
|
|
|
|
{ error: "Failed to fetch logs" },
|
|
|
|
{ status: 500 }
|
|
|
|
);
|
|
|
|
}
|
2024-07-30 21:34:39 +02:00
|
|
|
}
|