lib/mia-js.js
function (host, reInit) {
        if (_.isEmpty(host.id) || !_.isString(host.id)) {
            throw new Error("Host configuration is invalid. Host id is missing or not a string");
        }
        if (_.isEmpty(host.host)) {
            throw new Error("Host configuration is invalid. Host is missing");
        }

        if (_.isString(host.host)) {
            host.host = [host.host];
        }

        if (!_.isArray(host.host)) {
            throw new Error("Host configuration is invalid. Host should be array or string");
        }

        var router = new express.Router();

        if (reInit === false) {
            // Check if host is already defined. Use same router instance to merge routes
            for (var index in _vhosts) {
                for (var vh in _vhosts[index]["host"]) {
                    if (_vhosts[index]["host"][vh] == host.host) {
                        router = _vhosts[index]["router"];
                    }
                }
            }
        }

        _vhosts[host.id] = {
            host: host.host,
            router: router,
            http: !host.listener ? true : host.listener && host.listener.http || null,
            https: !host.listener ? true : host.listener && host.listener.https || null
        };

        _applyRouterConfig(_vhosts[host.id]["router"]);
        _customInitFuncton(_vhosts[host.id]["router"]);
    }
function (host, reInit) {
        if (_.isEmpty(host.id) || !_.isString(host.id)) {
            throw new Error("Host configuration is invalid. Host id is missing or not a string");
        }
        if (_.isEmpty(host.host)) {
            throw new Error("Host configuration is invalid. Host is missing");
        }

        if (_.isString(host.host)) {
            host.host = [host.host];
        }

        if (!_.isArray(host.host)) {
            throw new Error("Host configuration is invalid. Host should be array or string");
        }

        var router = new express.Router();

        if (reInit === false) {
            // Check if host is already defined. Use same router instance to merge routes
            for (var index in _vhosts) {
                for (var vh in _vhosts[index]["host"]) {
                    if (_vhosts[index]["host"][vh] == host.host) {
                        router = _vhosts[index]["router"];
                    }
                }
            }
        }

        _vhosts[host.id] = {
            host: host.host,
            router: router,
            http: !host.listener ? true : host.listener && host.listener.http || null,
            https: !host.listener ? true : host.listener && host.listener.https || null
        };

        _applyRouterConfig(_vhosts[host.id]["router"]);
        _customInitFuncton(_vhosts[host.id]["router"]);
    }
function ( host , reInit ) { if ( _ . isEmpty ( host . id ) || ! _ . isString ( host . id ) ) { throw new Error ( "Host configuration is invalid. Host id is missing or not a string" ) ; } if ( _ . isEmpty ( host . host ) ) { throw new Error ( "Host configuration is invalid. Host is missing" ) ; } if ( _ . isString ( host . host ) ) { host . host = [ host . host ] ; } if ( ! _ . isArray ( host . host ) ) { throw new Error ( "Host configuration is invalid. Host should be array or string" ) ; } var router = new express . Router ( ) ; if ( reInit === false ) { // Check if host is already defined. Use same router instance to merge routes for ( var index in _vhosts ) { for ( var vh in _vhosts [ index ] [ "host" ] ) { if ( _vhosts [ index ] [ "host" ] [ vh ] == host . host ) { router = _vhosts [ index ] [ "router" ] ; } } } } _vhosts [ host . id ] = { host : host . host , router : router , http : ! host . listener ? true : host . listener && host . listener . http || null , https : ! host . listener ? true : host . listener && host . listener . https || null } ; _applyRouterConfig ( _vhosts [ host . id ] [ "router" ] ) ; _customInitFuncton ( _vhosts [ host . id ] [ "router" ] ) ; }
Parse virtual host definition from mia.js global environment configuration
@param {Object} host
@param {Boolean} reInit
@private
Parse virtual host definition from mia . js global environment configuration