La Radio di Biagi - server
This project contains the server side of the LRdB project. If you haven't, you should first visit the client repository and its corresponding Wiki to find out more about the project and its goals.
Language warning 🇨🇿: Since the primary users of this project were czech, user documentation, log messages and page contents are in Czech.
⚠️
Deprecation notice This project is no longer maintained. Some modifications may be necessary before it can be run successfully. If you intend on using this software, make sure all dependencies are up to date to protect yourself against security vulnerabilities.
Requirements
node.js
runtime andnpm
pm2
- Redis server
- MySQL compatible database
- Firebase project key
Installation
- Pull all project requirements
npm install
- Replicate database schema
mysql -u *mysql_user* -p *database_name* < db_dump.sql
Usage
See the pm2 documentation - ecosystem.config.js
is the ecosystem file.
Configuration
The server configuration is stored in three files:
ecosystem.config.js
is used to set up environment variables for the runtime and contains the path to the Firebase account credentials.src/config.js
contains the Redis server configuration.src/routes/fmf/config.js
is the main config file of the application. It contains the database configuration, username-password combinations and firebase settings, as well as the client-verifying magic string.
Execution flow
New message sending
- Sender logs in to the admin panel (appropriate session is created).
- Sender fills in the new message form and sends it to the server.
- Server verifies the validity of the message data. If valid, the data is placed in a query and added to the 'Message' table (
newMsgQuery
). - Server periodically checks the database for new messages (
pollDB()
). If an unsent message is found that is due, its contents are passed to the Firebase API, which sends it to the registered users. - Once the API confirms it received the message, it is added to the 'Sent' table.
Confirming received messages
- Client sends a POST request to the server containing the verifying magic string, their unique client token and the ID of the received message.
- If both the magic and the ID are valid, the confirmation is added to the 'Viewed' table.
Feedback
Bugs and feedback reports are saved into ./bugs
and ./feedback
respectively.