src/server/ApiRequestHandler.js
function buildRoutes(router, apiOrBuilder) {
    // if it's a builder function, build it...
    let pathPrefix = null;
    let api = null;
    let registry = null;
    let instanceName = null;
    if (_.isObject(apiOrBuilder)) {
        pathPrefix = apiOrBuilder.path;
        api = apiOrBuilder.api;
        registry = apiOrBuilder.registry;
        instanceName = apiOrBuilder.instanceName;
    } else {
        api = apiOrBuilder;
    }

    if (_.isFunction(api)) {
        api = api();
    }

    if (!registry && _.isFunction(api.registry)) {
        registry = api.registry();
    }

    if (!registry) {
        // print errors here
        return;
    }

    _.forEach(registry, (value, key) => {
        if (_.isArray(value)) {
            _.forEach(value, item => buildRoute(router, api, key, item, pathPrefix, instanceName));
        } else {
            buildRoute(router, api, key, value, pathPrefix, instanceName);
        }
    });
}
function buildRoutes(router, apiOrBuilder) {
    // if it's a builder function, build it...
    let pathPrefix = null;
    let api = null;
    let registry = null;
    let instanceName = null;
    if (_.isObject(apiOrBuilder)) {
        pathPrefix = apiOrBuilder.path;
        api = apiOrBuilder.api;
        registry = apiOrBuilder.registry;
        instanceName = apiOrBuilder.instanceName;
    } else {
        api = apiOrBuilder;
    }

    if (_.isFunction(api)) {
        api = api();
    }

    if (!registry && _.isFunction(api.registry)) {
        registry = api.registry();
    }

    if (!registry) {
        // print errors here
        return;
    }

    _.forEach(registry, (value, key) => {
        if (_.isArray(value)) {
            _.forEach(value, item => buildRoute(router, api, key, item, pathPrefix, instanceName));
        } else {
            buildRoute(router, api, key, value, pathPrefix, instanceName);
        }
    });
}
function buildRoutes ( router , apiOrBuilder ) { // if it's a builder function, build it... let pathPrefix = null ; let api = null ; let registry = null ; let instanceName = null ; if ( _ . isObject ( apiOrBuilder ) ) { pathPrefix = apiOrBuilder . path ; api = apiOrBuilder . api ; registry = apiOrBuilder . registry ; instanceName = apiOrBuilder . instanceName ; } else { api = apiOrBuilder ; } if ( _ . isFunction ( api ) ) { api = api ( ) ; } if ( ! registry && _ . isFunction ( api . registry ) ) { registry = api . registry ( ) ; } if ( ! registry ) { // print errors here return ; } _ . forEach ( registry , ( value , key ) => { if ( _ . isArray ( value ) ) { _ . forEach ( value , item => buildRoute ( router , api , key , item , pathPrefix , instanceName ) ) ; } else { buildRoute ( router , api , key , value , pathPrefix , instanceName ) ; } } ) ; }
should build a catch all route for pathPrefix ??
should build a catch all route for pathPrefix ??