A lightweight REST API microservice for managing notifications. Supports adding, retrieving, and clearing notifications.
POST - add a notification
http://localhost:3002/api/notifications
GET — get all notifications
http://localhost:3002/api/notifications
DELETE — clear all notifications
http://localhost:3002/api/notifications
| Type | When to use |
|---|---|
| success | Action completed successfully |
| error | Something went wrong |
| warning | User should be aware of something |
| info | General information |
Request:
POST /api/notificationsBody:
{
"message": "your message",
"type": "success | error | warning | info"
}Example:
async function createNotification() {
const res = await fetch('http://localhost:3002/api/notifications', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: 'Profile saved succesfully',
type: 'info'
})
});
const data = await res.json();
console.log(data)
}Data received
[
{
"id": 1779067121404,
"message": "Profile saved succesfully",
"type": "info",
"timestamp": "2026-05-18T01:18:41.404Z"
}
]Request:
GET /api/notificationsExample:
async function getNotifications() {
const res = await fetch('http://localhost:3002/api/notifications');
const data = await res.json();
console.log(data)
}Data received:
[
{
"id": 1779067921144,
"message": "Password updated successfully",
"type": "info",
"timestamp": "2026-05-18T01:32:01.144Z"
},
{
"id": 1779067121404,
"message": "Profile saved succesfully",
"type": "info",
"timestamp": "2026-05-18T01:18:41.404Z"
}
]Request:
DELETE /api/notificationsExample:
async function deleteNotifications() {
const res = await fetch('http://localhost:3002/api/notifications', {
method: 'DELETE'
});
const data = await res.json()
console.log(data)
}Data received:
{ success: true, message: "All notifications cleared" }