e33f6f7cfd
This commit adds a websocket server that clients can connect and authenticate to. Once they're authenticated, they will start to receive relevant events. One issue is that the server does not ping for dead connections yet and the fact that new listeners for the guild are added for each connection. There is also the bug in WatchedGuild that prevents other bridge users from seeing eachother's messages.
26 lines
No EOL
726 B
JavaScript
26 lines
No EOL
726 B
JavaScript
import http from "node:http";
|
|
import express from "express";
|
|
import apiRoute from "./routes/api.js";
|
|
import { mainHttpListenPort } from "./config.js";
|
|
import { bot } from "./common.js";
|
|
import GatewayServer from "./GatewayServer.js";
|
|
|
|
// might introduce bugs and probably a bad idea
|
|
Object.freeze(Object.prototype);
|
|
Object.freeze(Object);
|
|
|
|
|
|
const app = express();
|
|
const httpServer = http.createServer(app);
|
|
const gatewayServer = new GatewayServer(httpServer, {
|
|
path: "/gateway"
|
|
});
|
|
|
|
app.use(express.json());
|
|
app.use("/", express.static("frontend/public/"));
|
|
app.use("/api/v1", apiRoute);
|
|
|
|
httpServer.listen(mainHttpListenPort, () => {
|
|
console.log(`server main: listen on ${mainHttpListenPort}`);
|
|
bot.connect();
|
|
}); |