diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..695f9cd --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +.direnv +.envrc diff --git a/index.js b/index.js index 9199e01..8c65e0c 100644 --- a/index.js +++ b/index.js @@ -3,10 +3,12 @@ import * as http from 'http'; import * as socketio from 'socket.io'; import * as fs from 'fs'; import * as path from 'path'; +import * as mqtt from 'mqtt'; const app = express(); const server = http.createServer(app); const io = new socketio.Server(server); +const client = mqtt.connect("mqtt://mqtt.hacklab"); const connections = new Set(); @@ -111,6 +113,8 @@ app.get('/reset', (req, res) => { let rawTimestamp = req.query.time || req.query.timestamp; applyDelta(res, resetTimer(name, rawTimestamp)); + + client.publish("time-since-last/reset-occurred", name); }); app.get('/history', (req, res) => { diff --git a/package.json b/package.json index 0f26b77..a609f04 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "express": "^5.1.0", + "mqtt": "^5.15.1", "socket.io": "^4.8.1" }, "type": "module"