RafalWilinski / express-status-monitor

🚀 Realtime Monitoring solution for Node.js/Express.js apps, inspired by status.github.com, sponsored by https://dynobase.dev
https://dynobase.dev/
MIT License
3.61k stars 255 forks source link

Own Socket instance? #181

Open Pajsen9263 opened 2 years ago

Pajsen9263 commented 2 years ago

How do I provide my own socket instance? I tried with const statusMonitor = require('express-status-monitor')({websocket: io}) . I've also tried with the port my server is on. (It's behind Nginx Proxy Manager, but my other socket stuff work).

tahayk commented 2 years ago

@Pajsen9263 try this code:

const express = require('express');
const PORT = 3000;
const HOST = '127.0.0.1';

let app = express();
const server = app.listen(PORT, HOST, () => {
    console.log(`WS App listening on http://${HOST}:${PORT}`);
    console.log('Press Ctrl+C to quit.');
});
let io = require('socket.io')(server, {
    allowEIO3: true // this is required because ESM is using an old socket.io version
})
app.use(require('express-status-monitor')({
    websocket: io,
}));
fedot199614 commented 2 years ago

@tahayk it is work for me thanks