From f700cad564761b22438c4d0a0f3465c43da28735 Mon Sep 17 00:00:00 2001 From: Sean O'Connor Date: Wed, 20 Nov 2024 23:35:49 -0500 Subject: [PATCH] Remove delete routes --- src/app/api/participants/[id]/route.ts | 32 -------------------------- src/app/api/studies/[id]/route.ts | 32 -------------------------- 2 files changed, 64 deletions(-) delete mode 100644 src/app/api/participants/[id]/route.ts delete mode 100644 src/app/api/studies/[id]/route.ts diff --git a/src/app/api/participants/[id]/route.ts b/src/app/api/participants/[id]/route.ts deleted file mode 100644 index 2cc878f..0000000 --- a/src/app/api/participants/[id]/route.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { eq } from "drizzle-orm"; -import { NextResponse } from "next/server"; -import { auth } from "@clerk/nextjs/server"; -import { db } from "~/db"; -import { participants } from "~/db/schema"; - - -export async function DELETE(request: Request, { params }: any) { - const { userId } = await auth(); - - if (!userId) { - return new NextResponse("Unauthorized", { status: 401 }); - } - - const participantId = parseInt(params.id); - - try { - const result = await db - .delete(participants) - .where(eq(participants.id, participantId)) - .execute(); - - if (result.rowCount === 0) { - return new NextResponse("Not Found", { status: 404 }); - } - - return new NextResponse(null, { status: 204 }); // No content for successful deletion - } catch (error) { - console.error("Error deleting participant:", error); - return new NextResponse("Internal Server Error", { status: 500 }); - } -} \ No newline at end of file diff --git a/src/app/api/studies/[id]/route.ts b/src/app/api/studies/[id]/route.ts deleted file mode 100644 index 3cad87e..0000000 --- a/src/app/api/studies/[id]/route.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { eq } from "drizzle-orm"; -import { NextResponse } from "next/server"; -import { auth } from "@clerk/nextjs/server"; -import { db } from "~/db"; -import { studyTable } from "~/db/schema"; - -export async function DELETE(request: Request, { params }: { params: { id: string } }) { - const { userId } = await auth(); - - if (!userId) { - return new NextResponse("Unauthorized", { status: 401 }); - } - - const { id } = await params; - const studyId = parseInt(id); - - try { - const result = await db - .delete(studyTable) - .where(eq(studyTable.id, studyId)) - .execute(); - - if (result.rowCount === 0) { - return new NextResponse("Not Found", { status: 404 }); - } - - return new NextResponse(null, { status: 204 }); - } catch (error) { - console.error("Error deleting study:", error); - return new NextResponse("Internal Server Error", { status: 500 }); - } - } \ No newline at end of file