This is a server component for my MMM-MessageToMirror module, which is a module for MagicMirror. See my magic repository for more information.
This component is a service used by the mirror to register, and used by the app to get available screens and to send messages.
Clone the repository from github.
In order to deploy to Firebase hosting, you need to init firebase:
firebase init functions
Select project and Typescript, but do not overwrite existing files.
Run npm install:
cd functions
npm install
Select functions, then select project and TypeScript.
cd functions
tsc; firebase serve --only functions
Deploy command:
firebase deploy --only functions
Functions URL: https://us-central1-magic-acf51.cloudfunctions.net/app/
In order to use this API, you must authenticate using Google Firebase Auth, and pass the Firebase ID Token in the Authorization http header like this:
'Authorization': 'Bearer <token>'
Used by the MMM-MagicMessage MagicMirror module to register a new screen. Body contains:
{
"name": "Mirror name from config",
"emails": [
"email 1",
"email 2"
//...
]
}The email array is a list of legal users.
Used by the app to send message to mirror. Body:
{
"message": "The message to the mirror",
"sentBy": "email",
"lifetime": 60 // Minutes the message shall live
}The :id is the screen id. The screen module is using a uuid for this.
Used by the app to get the name and id of the screens that the authenticated user can send messages to. The result is an array of screen objects:
[
{
"name": "Screen display name",
"key": "Unique screen key"
}
//...
]