From 48a2255bfc45ffcfb0b39ffefdd57cbacf8b36df Mon Sep 17 00:00:00 2001 From: dujinkim Date: Fri, 18 Jul 2025 07:52:02 +0000 Subject: (대표님) 파일관리변경, 클라IP추적, 실시간알림, 미들웨어변경, 알림API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/notifications/read-all/route.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 app/api/notifications/read-all/route.ts (limited to 'app/api/notifications/read-all') diff --git a/app/api/notifications/read-all/route.ts b/app/api/notifications/read-all/route.ts new file mode 100644 index 00000000..f53bbbbf --- /dev/null +++ b/app/api/notifications/read-all/route.ts @@ -0,0 +1,26 @@ +// app/api/notifications/read-all/route.ts +import { NextRequest, NextResponse } from 'next/server'; +import { getServerSession } from 'next-auth'; +import { authOptions } from "@/app/api/auth/[...nextauth]/route" + +export async function PATCH(request: NextRequest) { + try { + const session = await getServerSession(authOptions); + if (!session?.user?.id) { + return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + } + + const notifications = await markAllNotificationsAsRead(session.user.id); + + return NextResponse.json({ + success: true, + updatedCount: notifications.length + }); + } catch (error) { + console.error('Error marking all notifications as read:', error); + return NextResponse.json( + { error: 'Failed to mark all notifications as read' }, + { status: 500 } + ); + } +} -- cgit v1.2.3