lib/processRoutes.js
function processRoutes(handler, uriContext, routes) {
    return routes.map(setupRoute);

    /**
     * @param {(PreReq|pageAdapter)[]} adapters - Array of adapters and Hapi route prerequisites for processing
     *                                            an incoming request
     * @param {pageFilter} pageFilter           - Function for performing post-processing on page object before
     *                                            templating begins
     * @param {string} method                   - HTTP method for the route
     * @param {string} path                     - Path for the route
     * @param {module:processRoutes.Context} context
     *                                          - Data that should be made available to the adapters and route handler
     *
     * @returns {object} Hapi route options object
     */
    function setupRoute({adapters, pageFilter, method, path, context}) {
        const allAdaptersAndPreHandlers = flattenDeep(adapters);
        const preHandlers = allAdaptersAndPreHandlers.filter(x => isPreHandler(x));
        const pageAdapters = allAdaptersAndPreHandlers.filter(x => !isPreHandler(x));


        const app = {
            context,
            adapters: pageAdapters
        };
        if (pageFilter) {
            app.pageFilter = pageFilter;
        }

        const pre = preHandlers.map(mapToWrappedHandler);

        return {
            method,
            path: uriContext + path,
            handler,
            config: {
                state: {
                    failAction: 'log'
                },
                app,
                pre
            }
        };
    }

}
function processRoutes(handler, uriContext, routes) {
    return routes.map(setupRoute);

    /**
     * @param {(PreReq|pageAdapter)[]} adapters - Array of adapters and Hapi route prerequisites for processing
     *                                            an incoming request
     * @param {pageFilter} pageFilter           - Function for performing post-processing on page object before
     *                                            templating begins
     * @param {string} method                   - HTTP method for the route
     * @param {string} path                     - Path for the route
     * @param {module:processRoutes.Context} context
     *                                          - Data that should be made available to the adapters and route handler
     *
     * @returns {object} Hapi route options object
     */
    function setupRoute({adapters, pageFilter, method, path, context}) {
        const allAdaptersAndPreHandlers = flattenDeep(adapters);
        const preHandlers = allAdaptersAndPreHandlers.filter(x => isPreHandler(x));
        const pageAdapters = allAdaptersAndPreHandlers.filter(x => !isPreHandler(x));


        const app = {
            context,
            adapters: pageAdapters
        };
        if (pageFilter) {
            app.pageFilter = pageFilter;
        }

        const pre = preHandlers.map(mapToWrappedHandler);

        return {
            method,
            path: uriContext + path,
            handler,
            config: {
                state: {
                    failAction: 'log'
                },
                app,
                pre
            }
        };
    }

}
function processRoutes ( handler , uriContext , routes ) { return routes . map ( setupRoute ) ; /**
     * @param {(PreReq|pageAdapter)[]} adapters - Array of adapters and Hapi route prerequisites for processing
     *                                            an incoming request
     * @param {pageFilter} pageFilter           - Function for performing post-processing on page object before
     *                                            templating begins
     * @param {string} method                   - HTTP method for the route
     * @param {string} path                     - Path for the route
     * @param {module:processRoutes.Context} context
     *                                          - Data that should be made available to the adapters and route handler
     *
     * @returns {object} Hapi route options object
     */ function setupRoute ( { adapters , pageFilter , method , path , context } ) { const allAdaptersAndPreHandlers = flattenDeep ( adapters ) ; const preHandlers = allAdaptersAndPreHandlers . filter ( x => isPreHandler ( x ) ) ; const pageAdapters = allAdaptersAndPreHandlers . filter ( x => ! isPreHandler ( x ) ) ; const app = { context , adapters : pageAdapters } ; if ( pageFilter ) { app . pageFilter = pageFilter ; } const pre = preHandlers . map ( mapToWrappedHandler ) ; return { method , path : uriContext + path , handler , config : { state : { failAction : 'log' } , app , pre } } ; } }
Converts an array of Windshield routes into a an array of Hapi routes.
Each route will use the same handler method, which accesses a set of
Windshield adapters from the route to build a page object, and define a
layout template to compile the page object into a web page.

@param {handler} handler                     - Hapi route handler method
@param {module:processRoutes.Route[]} routes - Array of Windshield route objects, which are processed into Hapi routes
@param {string} uriContext                   - the URI context to be prepended to the paths of each route.

@returns {object[]} - An array of Hapi route options objects
Converts an array of Windshield routes into a an array of Hapi routes . Each route will use the same handler method which accesses a set of Windshield adapters from the route to build a page object and define a layout template to compile the page object into a web page .