refactor: replace patch with delete for /api/document (#930)
This commit is contained in:
parent
c937db3050
commit
5b4ad941d3
3 changed files with 17 additions and 14 deletions
|
|
@ -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 });
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue