bridgecord/index.js

28 lines
760 B
JavaScript
Raw Normal View History

import http from "node:http";
import express from "express";
import apiRoute from "./routes/api.js";
import { mainHttpListenPort } from "./config.js";
2022-02-15 14:24:46 +02:00
import { bot, logger } from "./common.js";
import GatewayServer from "./GatewayServer.js";
2022-02-15 14:24:46 +02:00
const log = logger("log", "ServerMain");
2022-02-02 20:24:14 +02:00
// 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());
2022-02-02 20:24:14 +02:00
app.use("/", express.static("frontend/public/"));
app.use("/api/v1", apiRoute);
httpServer.listen(mainHttpListenPort, () => {
2022-02-15 14:24:46 +02:00
log(`http listen on ${mainHttpListenPort}`);
bot.connect();
});