Closed rikkertkoppes closed 4 years ago
discussion in #20
This allows running http and ws on the same http(s) server. Useful for combining mhub functionality with for example an express server
Working example:
const express = require("express"); const path = require("path"); const app = express(); const { MServer } = require("mhub"); let port = process.env.PORT || 5000; // express server const server = require("http").createServer(app); app.use(express.static(path.join(__dirname, "build"))); app.get("/", function(req, res) { res.sendFile(path.join(__dirname, "build", "index.html")); }); // mhub server let mserver = new MServer({ listen: [ { type: "websocket", server } ], bindings: [], nodes: { default: "HeaderStore" }, storage: "./storage", users: {}, rights: { "": true } }); mserver.init(); server.listen(port, () => { console.log(`server running on port ${port}`); });
closed in favor of subclassing, see #20
discussion in #20
This allows running http and ws on the same http(s) server. Useful for combining mhub functionality with for example an express server
Working example: