refactor(ux): consolidate BMAD skills, update design system, and clean up Prisma generated client

This commit is contained in:
Sepehr Ramezani
2026-04-19 19:21:27 +02:00
parent 5296c4da2c
commit 25529a24b8
2476 changed files with 127934 additions and 101962 deletions

View File

@@ -2,6 +2,7 @@ import { NextRequest, NextResponse } from 'next/server'
import { auth } from '@/auth'
import { prisma } from '@/lib/prisma'
import { revalidatePath } from 'next/cache'
import { deleteImageFileSafely, parseImageUrls } from '@/lib/image-cleanup'
export async function POST(req: NextRequest) {
try {
@@ -14,6 +15,12 @@ export async function POST(req: NextRequest) {
)
}
// Fetch notes with images before deleting for cleanup
const notesWithImages = await prisma.note.findMany({
where: { userId: session.user.id },
select: { id: true, images: true },
})
// Delete all notes for the user (cascade will handle labels-note relationships)
const result = await prisma.note.deleteMany({
where: {
@@ -21,6 +28,13 @@ export async function POST(req: NextRequest) {
}
})
// Clean up image files from disk (best-effort, don't block response)
const imageCleanup = Promise.allSettled(
notesWithImages.flatMap(note =>
parseImageUrls(note.images).map(url => deleteImageFileSafely(url, note.id))
)
)
// Delete all labels for the user
await prisma.label.deleteMany({
where: {
@@ -39,6 +53,9 @@ export async function POST(req: NextRequest) {
revalidatePath('/')
revalidatePath('/settings/data')
// Await cleanup in background (don't block response)
imageCleanup.catch(() => {})
return NextResponse.json({
success: true,
deletedNotes: result.count