UNPKG

observermc

Version:

A Node.js wrapper and API for multiple Minecraft Servers

32 lines (31 loc) 1.19 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); //tests var fs_1 = __importDefault(require("fs")); var crypto_1 = __importDefault(require("crypto")); var util_1 = require("./util"); function loadConfig(path) { var config; try { config = JSON.parse(fs_1.default.readFileSync(path, "utf-8")); } catch (_a) { util_1.Logger.error("Could not load the config file, creating example file..."); config = { servers: [], apiKey: crypto_1.default.randomBytes(20).toString("hex"), port: 3000, }; fs_1.default.writeFileSync(path, JSON.stringify(config)); util_1.Logger.log("Generated config file! Edit it and restart the wrapper to apply changes."); // Display API key console.log("\nYour auto-generated API key is: " + config.apiKey); console.log("DO NOT SHARE IT\n"); } return config; } var config = loadConfig("example-config.json"); // Test whatever you want here