_.each(config, function (options, key) { var host; if ('_' === key) { // skip special case keyword return; } if (!result[options.listen]) { // // <address:port> first time met - create base structure // result[options.listen] = { address: options.listen.split(':')[0] || '0.0.0.0', port: options.listen.split(':')[1] || 80, ssl: options.ssl, hosts: [] }; } // // fill in host (unique) that should be served by <address:port> // host = parseURL(options.mount).host || '*'; if (-1 === result[options.listen].hosts.indexOf(host)) { result[options.listen].hosts.push(host); } });
_.forEach(config, function (options, apiPath) { if ('_' === apiPath) { return; // skip special case keyword } var host = parseURL(options.mount).host || '*'; // For non-SSL. if (!_.contains(result[options.listen].hosts, host)) { result[options.listen].hosts.push(host); } // For SSL. if (options.ssl && !_.contains(result[options.ssl.listen].hosts, host)) { result[options.ssl.listen].hosts.push(host); } });