Small Node.js server for MQTT telemetry.
- listens to
broker.hivemq.comondhruv/meter/# - stores telemetry in PostgreSQL through Prisma
- exposes
GET /api/v1/logs - exposes
GET /api/v1/trends
- Install deps
npm install- Set up
.env
DATABASE_URL=postgresql://user:pass@host:5432/eineage
PORT=3000
MQTT_HOST=broker.hivemq.com
MQTT_PORT=1883
MQTT_TOPIC="xyz/meter/#"- Run Prisma
npm run prisma:generate
npm run prisma:migrate- Start the server
npm run devcurl "http://localhost:3000/api/v1/logs?model=esp32&type=energy_demand"
curl "http://localhost:3000/api/v1/trends?model=esp32&range=1d&type=elec_measurements"