UNPKG

twokeys-server

Version:

Server for 2Keys

57 lines (53 loc) 2.1 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); /** Copyright 2018 Kishan Sambhi This file is part of 2Keys. 2Keys is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 2Keys is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with 2Keys. If not, see <https://www.gnu.org/licenses/>. */ /** * @overview Config loader for 2Keys */ const fs_1 = require("fs"); const path_1 = require("path"); const yaml_1 = __importDefault(require("yaml")); const util_1 = require("util"); const constants_1 = require("./constants"); const logger_1 = __importDefault(require("./logger")); const readFile = util_1.promisify(fs_1.readFile); // For easier handling with async const logger = new logger_1.default({ name: "config" }); async function config_loader() { try { const config = await readFile(path_1.join(process.cwd(), constants_1.CONFIG_FILE)); const parsedConfig = yaml_1.default.parse(config.toString()); return parsedConfig; } catch (err) { throw err; // Handled by callback } } exports.config_loader = config_loader; async function userspace_config_loader() { try { const config = await readFile(constants_1.DEFAULT_USERSPACE_CONFIG); const parsed_config = yaml_1.default.parse(config.toString()); return parsed_config; } catch (err) { throw err; // Handled by callback } } exports.userspace_config_loader = userspace_config_loader; //# sourceMappingURL=config.js.map