refactor: replace patch with delete for /api/document (#930)

This commit is contained in:
Jeremy 2025-04-14 00:11:44 -07:00 committed by GitHub
parent c937db3050
commit 5b4ad941d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 14 deletions

View file

@ -77,19 +77,22 @@ export async function POST(request: Request) {
return Response.json(document, { status: 200 });
}
export async function PATCH(request: Request) {
export async function DELETE(request: Request) {
const { searchParams } = new URL(request.url);
const id = searchParams.get('id');
const { timestamp }: { timestamp: string } = await request.json();
const timestamp = searchParams.get('timestamp');
if (!id) {
return new Response('Missing id', { status: 400 });
}
if (!timestamp) {
return new Response('Missing timestamp', { status: 400 });
}
const session = await auth();
if (!session || !session.user) {
if (!session?.user?.id) {
return new Response('Unauthorized', { status: 401 });
}