var glob = require('glob');

/**
 * @param {String} apiPath
 *
 * @returns {Object}
 */
module.exports = function(apiPath) {
    var apiRouters = {}, apiVersion, router;

    var routersFilesPaths = glob.sync(apiPath + '/**/routes/**/*.js');

    routersFilesPaths.forEach(function(routerFilePath) {
        apiVersion = routerFilePath.match(/\/(v\d+)\//)[1];
        if (!apiRouters[apiVersion]) {
            apiRouters[apiVersion] = [];
        }

        router = require(routerFilePath);
        apiRouters[apiVersion].push(router);
    });

    return apiRouters;
};

@@ -222,16 +222,17 @@
 **/route
+r
 s/**/*.j

load routers from "routers" directories