Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | /** * Mark All Notifications as Read API Route * * POST /api/notifications/read-all */ import { NextRequest, NextResponse } from 'next/server'; import { withAuth, withErrorHandling, successResponse, ApiSuccessResponse, } from '@/lib/api'; import { RouteContext } from '@/lib/api/middleware'; import { prisma } from '@/lib/prisma'; import { Session } from 'next-auth'; /** * POST /api/notifications/read-all * * Mark all unread notifications as read for the authenticated user. */ async function handlePost( _request: NextRequest, _context: RouteContext | undefined, session: Session ): Promise<NextResponse<ApiSuccessResponse<{ success: boolean; updatedCount: number }>>> { const userId = session.user.id; const result = await prisma.notification.updateMany({ where: { userId, read: false, }, data: { read: true, }, }); return successResponse({ success: true, updatedCount: result.count, }); } export const POST = withErrorHandling(withAuth(handlePost)); |