fix: disable legacy server-side JavaScript in webroot by default in YAML-format confi...
[svrjs.git] / src / utils / configYamlAdapter.js
blob6c51104c09918ca3cd8dbe31932d1eea02721b2e
1 const YAML = require("yaml");
3 globalThis.YAML_SILENCE_WARNINGS = true;
4 globalThis.YAML_SILENCE_DEPRECATION_WARNINGS = true;
6 function configYAMLAdapter(configString) {
7 const parsedConfig = YAML.parse(configString);
8 if (parsedConfig === null) return {};
9 const config = Object.assign({}, parsedConfig.global);
10 if (parsedConfig.hosts) config.configVHost = parsedConfig.hosts;
11 else delete config.configVHost;
12 return config;
15 module.exports = configYAMLAdapter;