- Remove hardcoded database credentials from all scripts - Remove hardcoded Legacy API tokens from backend scripts - Remove hardcoded MQTT credentials from mqtt-test.js - Update backend/.env.example with DB_HOST, DB_USER, DB_PASSWORD, DB_NAME - Update backend/.env.example with LEGACY_API_TOKEN and MQTT credentials - Add dotenv config to all scripts requiring credentials - Create comprehensive documentation: - scripts/README.md - Root scripts usage - backend/scripts/README.md - Backend scripts documentation - MQTT_TESTING.md - MQTT testing guide - SECURITY_CREDENTIALS_CLEANUP.md - Security changes summary All scripts now read credentials from backend/.env instead of hardcoded values. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1.3 KiB
1.3 KiB
MQTT Testing
This document describes how to use the mqtt-test.js script for monitoring and testing MQTT alerts.
Environment Variables
The script requires MQTT credentials to be set in backend/.env:
# MQTT Configuration
MQTT_BROKER=mqtt://mqtt.eluxnetworks.net:1883
MQTT_USER=your-mqtt-username
MQTT_PASSWORD=your-mqtt-password
See backend/.env.example for the complete configuration template.
Usage
Monitor Mode (Listen for messages)
# Monitor deployment 21 (default)
node mqtt-test.js
# Monitor specific deployment
node mqtt-test.js 42
Send Mode (Publish test alert)
# Send test message to deployment 21
node mqtt-test.js send "Test alert message"
# Send test message to specific deployment
node mqtt-test.js send "Custom message text"
Message Format
MQTT messages follow this JSON structure:
{
"Command": "REPORT",
"body": "Alert message text",
"time": 1234567890
}
Security
⚠️ IMPORTANT:
- Never commit MQTT credentials to the repository
- Always use environment variables from
backend/.env - The
.envfile is git-ignored for security