Created
March 30, 2020 08:52
-
-
Save cenan/ac6bc995df5b28c6116d1b892349d1d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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