//read config params from YAML file
const fs = require('fs');
const YAML = require('yamljs');
const appConfig = YAML.load('config.yml');

module.exports.port = function() {
  let port = appConfig.port;
  let re = /^\d{1,5}$/;
  if ( ( ! re.test(port) ) || (port < 1) || (port > 65535) ) {
    let message = 'ERROR in config.yml: port [' + port + '] should be in the range 1-65535.';
    console.log(message);
    throw message;
  }
  return port;
}

module.exports.docRoot = function() {
  let docRoot = appConfig.docRoot;
  fs.stat(docRoot, (err, stats) => {
    if (err) {
        console.log("ERROR in config.yml: docRoot [" + docRoot + "] not valid.");
        throw err;
    }
    if ( ! stats.isDirectory() ) {
      let message = "ERROR in config.yml: docRoot [" + docRoot + "] not a directory.";
      console.log(message);
      throw message;
    }
  });

  return docRoot;
}

@@ -875,12 +875,311 @@
  docRoot;%0A%7D%0A
+%0Amodule.exports.hostName = function() %7B%0A  let hostName = appConfig.hostName;%0A  let re = /%5Cw/;%0A  if ( ! re.test(hostName) ) %7B%0A    let message = 'ERROR in config.yml: hostName %5B' + hostName + '%5D is not valid.';%0A    console.log(message);%0A    hostName = 'music.ownlifeful.com';%0A  %7D%0A  return hostName;%0A%7D%0A

Add hostName