Add data validation to the config

This commit is contained in:
Oliver Akins 2022-06-23 11:40:09 -06:00
parent 4506b97101
commit be25b95789
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99
2 changed files with 68 additions and 10 deletions

View file

@ -2,19 +2,11 @@
import "module-alias/register";
import startWebsocketServer from "./websocket";
import { loadConfig } from "./utils/config";
import { GameDB } from "./objects/GameDB";
import { Logger } from "tslog";
import toml from "toml";
import fs from "fs";
// load the config
try {
var configData = toml.parse(fs.readFileSync("config.toml", "utf-8"));
} catch {
console.error("Can't find config file. Exiting");
process.exit(1);
};
export const config: IConfig = configData;
export const config: IConfig = loadConfig();
// Define the logger
export const log = new Logger({