You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
import dotenv from "dotenv";
|
|
import {GameServer} from "./GameServer.js";
|
|
import pino from "pino"
|
|
import {Pool} from "pg";
|
|
|
|
const log = pino()
|
|
|
|
async function main(): Promise<void> {
|
|
const {parsed, error} = dotenv.config()
|
|
if (error || !parsed) {
|
|
throw error ?? Error("No parsed data.")
|
|
}
|
|
const clientSecret = parsed["DISCORD_CLIENT_SECRET"]
|
|
const appId = parsed["DISCORD_APP_ID"]
|
|
const botToken = parsed["DISCORD_BOT_TOKEN"]
|
|
const publicKey = parsed["DISCORD_PUBLIC_KEY"]
|
|
const listenPort = parseInt(parsed["HTTP_PORT"] ?? "5244")
|
|
const listenAddress = parsed["HTTP_ADDRESS"] ?? "127.0.0.1"
|
|
const cookieSecret = parsed["COOKIE_SECRET"] ?? "VERY SECRET STRING"
|
|
const pool = new Pool({
|
|
connectionString: parsed["DATABASE_URL"]
|
|
})
|
|
const deps = {
|
|
appId,
|
|
listenAddress,
|
|
listenPort,
|
|
clientSecret,
|
|
cookieSecret,
|
|
pool,
|
|
botToken,
|
|
publicKey,
|
|
}
|
|
await new GameServer(deps).initialize()
|
|
}
|
|
|
|
main().catch((err) => {
|
|
log.fatal(err, "Startup failed!")
|
|
})
|
|
|