src/support/startup/routes.js

Summary

Maintainability
A
0 mins
Test Coverage
"use strict";



const waigo = global.waigo,
  _ = waigo._;





/**
 * Setup route mappings.
 *
 * This sets up a `koa-trie-router` and maps routes to it using the 
 * [route mapper](../routeMapper.js.html).
 * 
 * @param {Object} App The application.
 */
module.exports = function*(App) {
  App.logger.debug('Setting up routes');

  var routeFiles = waigo.getItemsInFolder('routes');

  let routes = {};

  _.each(routeFiles, function(routeFile) {
    App.logger.debug('Loading ' + routeFile);

    _.merge(routes, waigo.load(routeFile));
  });

  App.routes = yield waigo.load('support/routeMapper')
    .setup(App, App.config.middleware, routes);
};