From 6de8a82e12c7b75ebdc46a35b8e4da2fa37ed654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Buget?= Date: Mon, 11 Sep 2023 08:10:02 +0200 Subject: [PATCH] wip: prepare DELETE /api/threads/[id] endpoint --- server/api/threads/[id]/delete.ts | 7 +++++++ server/api/threads/{[id].get.ts => [id]/get.ts} | 4 ++-- server/api/threads/{[id].post.ts => [id]/post.ts} | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 server/api/threads/[id]/delete.ts rename server/api/threads/{[id].get.ts => [id]/get.ts} (87%) rename server/api/threads/{[id].post.ts => [id]/post.ts} (96%) diff --git a/server/api/threads/[id]/delete.ts b/server/api/threads/[id]/delete.ts new file mode 100644 index 0000000..97c7740 --- /dev/null +++ b/server/api/threads/[id]/delete.ts @@ -0,0 +1,7 @@ +export default defineEventHandler(async (event: any) => { + const threadId = parseInt(getRouterParam(event, 'id') || '') + + console.log(`DELETE /api/threads/${threadId}`) + + return 'ok' +}) \ No newline at end of file diff --git a/server/api/threads/[id].get.ts b/server/api/threads/[id]/get.ts similarity index 87% rename from server/api/threads/[id].get.ts rename to server/api/threads/[id]/get.ts index d93c48f..8f353f3 100644 --- a/server/api/threads/[id].get.ts +++ b/server/api/threads/[id]/get.ts @@ -1,4 +1,4 @@ -import { prisma } from '../../../prisma/db' +import { prisma } from '../../../../prisma/db' export default defineEventHandler(async (event: any) => { const threadId = parseInt(getRouterParam(event, 'id') || '') @@ -18,6 +18,6 @@ export default defineEventHandler(async (event: any) => { const [latest] = thread.versions.slice(-1) result.latest = latest } -// console.log(result) + // console.log(result) return result; }) \ No newline at end of file diff --git a/server/api/threads/[id].post.ts b/server/api/threads/[id]/post.ts similarity index 96% rename from server/api/threads/[id].post.ts rename to server/api/threads/[id]/post.ts index a8a9c3b..943a7d9 100644 --- a/server/api/threads/[id].post.ts +++ b/server/api/threads/[id]/post.ts @@ -1,4 +1,4 @@ -import { prisma } from '../../../prisma/db' +import { prisma } from '../../../../prisma/db' type UpdateThreadRequest = { published: boolean