2022-02-06 03:48:28 +02:00
|
|
|
import http from "node:http";
|
2022-02-02 11:46:42 +02:00
|
|
|
import express from "express";
|
|
|
|
import apiRoute from "./routes/api.js";
|
|
|
|
import { mainHttpListenPort } from "./config.js";
|
|
|
|
import { bot } from "./common.js";
|
2022-02-06 03:48:28 +02:00
|
|
|
import GatewayServer from "./GatewayServer.js";
|
2022-02-02 11:46:42 +02:00
|
|
|
|
2022-02-02 20:24:14 +02:00
|
|
|
// might introduce bugs and probably a bad idea
|
|
|
|
Object.freeze(Object.prototype);
|
|
|
|
Object.freeze(Object);
|
|
|
|
|
|
|
|
|
2022-02-01 03:49:12 +02:00
|
|
|
const app = express();
|
2022-02-06 03:48:28 +02:00
|
|
|
const httpServer = http.createServer(app);
|
|
|
|
const gatewayServer = new GatewayServer(httpServer, {
|
|
|
|
path: "/gateway"
|
|
|
|
});
|
2022-02-01 03:49:12 +02:00
|
|
|
|
|
|
|
app.use(express.json());
|
2022-02-02 20:24:14 +02:00
|
|
|
app.use("/", express.static("frontend/public/"));
|
2022-02-01 03:49:12 +02:00
|
|
|
app.use("/api/v1", apiRoute);
|
|
|
|
|
2022-02-06 03:48:28 +02:00
|
|
|
httpServer.listen(mainHttpListenPort, () => {
|
2022-02-01 03:49:12 +02:00
|
|
|
console.log(`server main: listen on ${mainHttpListenPort}`);
|
2022-02-02 11:46:42 +02:00
|
|
|
bot.connect();
|
2022-02-01 03:49:12 +02:00
|
|
|
});
|