2017-10-05 14:27:43 -06:00
|
|
|
/* tslint:disable:ordered-imports */
|
2017-10-03 13:07:05 -06:00
|
|
|
import "./configureAlias";
|
|
|
|
import "env";
|
2017-10-05 14:27:43 -06:00
|
|
|
import "./configureLogger";
|
2017-10-03 13:07:05 -06:00
|
|
|
|
|
|
|
import log from "@common/logger";
|
2018-05-24 10:36:16 -06:00
|
|
|
import {Server} from "http";
|
2017-10-09 08:09:08 -06:00
|
|
|
import * as WebSocket from "ws";
|
|
|
|
|
2018-06-25 02:20:44 -06:00
|
|
|
import { ServerState } from "./state";
|
|
|
|
import { createApp } from "./app";
|
|
|
|
import { WebSocketApi } from "./websocket";
|
|
|
|
|
|
|
|
const state = new ServerState();
|
|
|
|
const app = createApp(state);
|
|
|
|
const webSocketApi = new WebSocketApi(state);
|
2017-09-10 21:38:07 -06:00
|
|
|
|
2017-09-07 12:26:23 -06:00
|
|
|
const port = +(process.env.PORT || 8080);
|
|
|
|
const host = process.env.HOST || "0.0.0.0";
|
2017-09-10 21:38:07 -06:00
|
|
|
|
2017-10-09 08:09:08 -06:00
|
|
|
const server = new Server(app);
|
2018-05-24 10:36:16 -06:00
|
|
|
const webSocketServer = new WebSocket.Server({server});
|
2018-06-25 02:20:44 -06:00
|
|
|
webSocketServer.on("connection", webSocketApi.handleConnection);
|
2017-10-09 08:09:08 -06:00
|
|
|
|
2018-05-24 10:36:16 -06:00
|
|
|
state.start();
|
2017-09-10 21:38:07 -06:00
|
|
|
server.listen(port, host, () => {
|
2017-09-26 12:43:25 -06:00
|
|
|
log.info(`listening at ${host}:${port}`);
|
2017-09-07 12:26:23 -06:00
|
|
|
});
|