Skip to content

Instantly share code, notes, and snippets.

@cenan
Created March 30, 2020 08:52
Show Gist options
  • Save cenan/ac6bc995df5b28c6116d1b892349d1d9 to your computer and use it in GitHub Desktop.
Save cenan/ac6bc995df5b28c6116d1b892349d1d9 to your computer and use it in GitHub Desktop.
import * as fs from "fs";
import * as path from "path";
import * as express from 'express';
import * as bodyParser from "body-parser";
import { Server, ServerConfig } from "./Server";
import { deserialize } from "serializr";
let serverConfig: ServerConfig = {
httpPort: 4444,
redisHost: "127.0.0.1",
redisPort: 6379,
apiServerAddress: "",
maxQuestionCount: 22,
gameServers: []
};
const app = express();
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "ejs");
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, 'public')));
fs.readFile("server-config.json", "utf8", (err, data) => {
if (!err) {
serverConfig = deserialize(ServerConfig, JSON.parse(data));
} else {
console.log(err);
process.exit(127);
}
const server = new Server(serverConfig);
server.listen(app);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment