feat: implement notifications system with API endpoints for fetching and marking notifications as read
This commit is contained in:
35
test-notifications-api.mjs
Normal file
35
test-notifications-api.mjs
Normal 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();
|
||||
Reference in New Issue
Block a user