index.js
function makeRouter() {

    // Solving arguments
    var args = [].slice.call(arguments);

    var beforeMiddlewares = args.slice(0, -1),
        routes = args[args.length - 1];

    var router = express.Router();

    routes.forEach(function(route) {
      if (!route.url)
        throw Error('dolman.router: one route has no url: ' + util.inspect(route));

      if (!route.action)
        throw Error('dolman.router: the route for url ' + route.url + ' has no action.');

      var actions = [].concat(route.action);

      // Storing the route
      routesMap.set(actions[0], route);

      // Applying before middlewares
      var routeMiddlewares = beforeMiddlewares.slice();

      // Validation
      if (route.validate)
        routeMiddlewares.push(middlewares.validate(types, route.validate));

      // Mask
      if (route.mask)
        routeMiddlewares.push(middlewares.mask(route.mask));

      // RAM cache
      if (route.cache)
        routeMiddlewares.push(middlewares.cache(cache, route.cache));

      // HTTP cache
      if (route.httpCache)
        routeMiddlewares.push(middlewares.httpCache(route.httpCache));

      // Determining the method
      var methods = [].concat(route.method || route.methods || 'ALL');

      methods.forEach(function(method) {
        router[method.toLowerCase()].apply(
          router,
          [route.url]
            .concat(routeMiddlewares)
            .concat(actions)
        );
      });
    });

    return router;
  }
function makeRouter() {

    // Solving arguments
    var args = [].slice.call(arguments);

    var beforeMiddlewares = args.slice(0, -1),
        routes = args[args.length - 1];

    var router = express.Router();

    routes.forEach(function(route) {
      if (!route.url)
        throw Error('dolman.router: one route has no url: ' + util.inspect(route));

      if (!route.action)
        throw Error('dolman.router: the route for url ' + route.url + ' has no action.');

      var actions = [].concat(route.action);

      // Storing the route
      routesMap.set(actions[0], route);

      // Applying before middlewares
      var routeMiddlewares = beforeMiddlewares.slice();

      // Validation
      if (route.validate)
        routeMiddlewares.push(middlewares.validate(types, route.validate));

      // Mask
      if (route.mask)
        routeMiddlewares.push(middlewares.mask(route.mask));

      // RAM cache
      if (route.cache)
        routeMiddlewares.push(middlewares.cache(cache, route.cache));

      // HTTP cache
      if (route.httpCache)
        routeMiddlewares.push(middlewares.httpCache(route.httpCache));

      // Determining the method
      var methods = [].concat(route.method || route.methods || 'ALL');

      methods.forEach(function(method) {
        router[method.toLowerCase()].apply(
          router,
          [route.url]
            .concat(routeMiddlewares)
            .concat(actions)
        );
      });
    });

    return router;
  }
function makeRouter ( ) { // Solving arguments var args = [ ] . slice . call ( arguments ) ; var beforeMiddlewares = args . slice ( 0 , - 1 ) , routes = args [ args . length - 1 ] ; var router = express . Router ( ) ; routes . forEach ( function ( route ) { if ( ! route . url ) throw Error ( 'dolman.router: one route has no url: ' + util . inspect ( route ) ) ; if ( ! route . action ) throw Error ( 'dolman.router: the route for url ' + route . url + ' has no action.' ) ; var actions = [ ] . concat ( route . action ) ; // Storing the route routesMap . set ( actions [ 0 ] , route ) ; // Applying before middlewares var routeMiddlewares = beforeMiddlewares . slice ( ) ; // Validation if ( route . validate ) routeMiddlewares . push ( middlewares . validate ( types , route . validate ) ) ; // Mask if ( route . mask ) routeMiddlewares . push ( middlewares . mask ( route . mask ) ) ; // RAM cache if ( route . cache ) routeMiddlewares . push ( middlewares . cache ( cache , route . cache ) ) ; // HTTP cache if ( route . httpCache ) routeMiddlewares . push ( middlewares . httpCache ( route . httpCache ) ) ; // Determining the method var methods = [ ] . concat ( route . method || route . methods || 'ALL' ) ; methods . forEach ( function ( method ) { router [ method . toLowerCase ( ) ] . apply ( router , [ route . url ] . concat ( routeMiddlewares ) . concat ( actions ) ) ; } ) ; } ) ; return router ; }
Router function.
Router function .