route.ts
525 bytes
| 1 | import { NextResponse } from 'next/server'; |
|---|---|
| 2 | import { currentUserId } from '@/auth'; |
| 3 | import { deletePreset } from '@/db/repositories'; |
| 4 | |
| 5 | export const runtime = 'nodejs'; |
| 6 | |
| 7 | type Params = { params: Promise<{ id: string }> }; |
| 8 | |
| 9 | export async function DELETE(_request: Request, { params }: Params) { |
| 10 | const userId = await currentUserId(); |
| 11 | if (!userId) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); |
| 12 | const { id } = await params; |
| 13 | await deletePreset(userId, id); |
| 14 | return NextResponse.json({ ok: true }); |
| 15 | } |
| 16 | |