svrjs-nextjs-website/app/api/uploadlogs/route.ts
2024-06-22 06:31:03 +03:00

20 lines
559 B
TypeScript

import { NextResponse } from 'next/server';
import clientPromise from '@/lib/db';
export async function POST(request: Request) {
const body = await request.json();
const { fileName, version, downloadLink, fileSize } = body;
const client = await clientPromise;
const db = client.db('downloadsDatabase');
const result = await db.collection('logs').insertOne({
date: new Date().toISOString().split('T')[0],
fileName,
version,
downloadLink,
fileSize,
});
return NextResponse.json({ success: true, id: result.insertedId });
}