Function to manage an application's notification system.
### How this function works
This function helps to manage the notification system of an application. It consists of an Express application with two routes: one to create the notifications and another to update it.
### Prerequisites
* You must have previous knowledge of **Firebase**.
### Function details
To install the notifications function you must add the required info to the form with the following parameters:
* **NOTIFICATIONS_COLLECTION_PATH:** The path to the collection that will be used to save the notifications.
* **NOTIFICATIONS_COUNTER_DOC_PATH:** The path to the document that will track the notifications count.
After filling the required data, click the Install button and after a few seconds you can start to use the function.
To create a notification, a POST request must be sent to `/notifications` endpoint. The body of the request should have the following structure:
```json
{
data: {
title: "Notification title",
description: "Notification description",
status: "success",
unread: true,
creator: {
id: "userId",
name: "John Doe",
photoUrl: "",
},
metadata: {
// Add metadata here
}
},
params: {
// Add params here
}
}
```
> The `data`, `params` and `title` properties are required.
> The `status` property is an enum with the following possible values: `'success', 'error', 'warning', 'inProgress', null`.
> The full URL of the operations will look like this: `https://us-central1-<project-id>.cloudfunctions.net/notifications`. See [Call an HTTP function](https://firebase.google.com/docs/functions/http-events#invoke_an_http_function) if you need more information.
To update an existing notification send a PATCH request to `/notifications/:notificationId`. The body of the request should have this form:
```json
{
data: {
title: "Notification title",
description: "Notification description",
status: "success",
unread: true,
},
params: {
// Add params here
}
}
```
> The `data` and `params` properties are required.
The `params` object should contain all the URL paramters of your collection path. For example, if the path is `users/{userId}/notifications` then the params should be:
```json
{
userId: 1
}
```