MCPcopy Create free account
hub / github.com/Fibi66/FeiControl / PATCH

Function PATCH

src/app/api/notifications/route.ts:128–159  ·  view source on GitHub ↗
(request: NextRequest)

Source from the content-addressed store, hash-verified

126}
127
128export async function PATCH(request: NextRequest) {
129 try {
130 const body = await request.json();
131 const { id, read, action } = body;
132
133 const notifications = await loadNotifications();
134
135 // Mark all as read
136 if (action === 'markAllRead') {
137 notifications.forEach((n) => (n.read = true));
138 await saveNotifications(notifications);
139 return NextResponse.json({ success: true, updated: notifications.length });
140 }
141
142 // Mark single notification as read/unread
143 if (id) {
144 const notification = notifications.find((n) => n.id === id);
145 if (!notification) {
146 return NextResponse.json({ error: 'Notification not found' }, { status: 404 });
147 }
148
149 notification.read = read !== undefined ? read : !notification.read;
150 await saveNotifications(notifications);
151 return NextResponse.json(notification);
152 }
153
154 return NextResponse.json({ error: 'Invalid request' }, { status: 400 });
155 } catch (error) {
156 console.error('Failed to update notification:', error);
157 return NextResponse.json({ error: 'Failed to update notification' }, { status: 500 });
158 }
159}
160
161export async function DELETE(request: NextRequest) {
162 try {

Callers

nothing calls this directly

Calls 2

loadNotificationsFunction · 0.85
saveNotificationsFunction · 0.85

Tested by

no test coverage detected