feat: implement notifications system with API endpoints for fetching and marking notifications as read

This commit is contained in:
2025-12-02 11:06:31 +01:00
parent fae7615818
commit 9b84c6b9e8
8 changed files with 694 additions and 13 deletions

View File

@@ -0,0 +1,35 @@
#!/usr/bin/env node
/**
* Test script to verify notifications API
*/
async function testNotificationsAPI() {
try {
console.log("Testing notifications API...");
// Test unread count endpoint
const unreadResponse = await fetch('http://localhost:3001/api/notifications/unread-count');
if (unreadResponse.ok) {
const unreadData = await unreadResponse.json();
console.log("✅ Unread count:", unreadData.unreadCount);
} else {
console.log("❌ Unread count endpoint failed:", unreadResponse.status);
}
// Test notifications list endpoint
const notificationsResponse = await fetch('http://localhost:3001/api/notifications');
if (notificationsResponse.ok) {
const notificationsData = await notificationsResponse.json();
console.log("✅ Notifications fetched:", notificationsData.notifications.length);
console.log("Sample notification:", notificationsData.notifications[0]);
} else {
console.log("❌ Notifications endpoint failed:", notificationsResponse.status);
}
} catch (error) {
console.error("Error testing API:", error);
}
}
testNotificationsAPI();