index.js
function specs() {
    var routes = {};

    // Reducing the app's recursive stack
    function reduceStack(path, items, item) {
      var nextPath;

      if (item.handle && item.handle.stack) {
        nextPath = join(path, (item.path || helpers.unescapeRegex(item.regexp) || ''));
        return items.concat(item.handle.stack.reduce(reduceStack.bind(null, nextPath), []));
      }

      if (item.route) {
        nextPath = join(path, (item.route.path || ''));
        return items.concat(item.route.stack.reduce(reduceStack.bind(null, nextPath), []));
      }

      return items.concat({
        handle: item.handle,
        path: path
      });
    }

    // Filtering the actions coming from dolman
    app._router.stack
      .reduce(reduceStack.bind(null, ''), [])
      .map(function(item) {
        return {
          route: routesMap.get(item.handle),
          path: item.path
        };
      })
      .filter(function(item) {
        return item.route && item.route.name;
      })
      .forEach(function(item) {
        var route = item.route,
            method = [].concat(route.method || route.methods)[0];

        var routeData = {
          path: item.path,
          name: route.name,
          method: !method || method === 'ALL' ? 'GET' : method
        };

        ['description'].forEach(function(k) {
          if (route[k])
            routeData[k] = route[k];
        });

        routes[route.name] = routeData;
      });

    return {
      formats: ['json'],
      methods: routes
    };
  }
function specs() {
    var routes = {};

    // Reducing the app's recursive stack
    function reduceStack(path, items, item) {
      var nextPath;

      if (item.handle && item.handle.stack) {
        nextPath = join(path, (item.path || helpers.unescapeRegex(item.regexp) || ''));
        return items.concat(item.handle.stack.reduce(reduceStack.bind(null, nextPath), []));
      }

      if (item.route) {
        nextPath = join(path, (item.route.path || ''));
        return items.concat(item.route.stack.reduce(reduceStack.bind(null, nextPath), []));
      }

      return items.concat({
        handle: item.handle,
        path: path
      });
    }

    // Filtering the actions coming from dolman
    app._router.stack
      .reduce(reduceStack.bind(null, ''), [])
      .map(function(item) {
        return {
          route: routesMap.get(item.handle),
          path: item.path
        };
      })
      .filter(function(item) {
        return item.route && item.route.name;
      })
      .forEach(function(item) {
        var route = item.route,
            method = [].concat(route.method || route.methods)[0];

        var routeData = {
          path: item.path,
          name: route.name,
          method: !method || method === 'ALL' ? 'GET' : method
        };

        ['description'].forEach(function(k) {
          if (route[k])
            routeData[k] = route[k];
        });

        routes[route.name] = routeData;
      });

    return {
      formats: ['json'],
      methods: routes
    };
  }
function specs ( ) { var routes = { } ; // Reducing the app's recursive stack function reduceStack ( path , items , item ) { var nextPath ; if ( item . handle && item . handle . stack ) { nextPath = join ( path , ( item . path || helpers . unescapeRegex ( item . regexp ) || '' ) ) ; return items . concat ( item . handle . stack . reduce ( reduceStack . bind ( null , nextPath ) , [ ] ) ) ; } if ( item . route ) { nextPath = join ( path , ( item . route . path || '' ) ) ; return items . concat ( item . route . stack . reduce ( reduceStack . bind ( null , nextPath ) , [ ] ) ) ; } return items . concat ( { handle : item . handle , path : path } ) ; } // Filtering the actions coming from dolman app . _router . stack . reduce ( reduceStack . bind ( null , '' ) , [ ] ) . map ( function ( item ) { return { route : routesMap . get ( item . handle ) , path : item . path } ; } ) . filter ( function ( item ) { return item . route && item . route . name ; } ) . forEach ( function ( item ) { var route = item . route , method = [ ] . concat ( route . method || route . methods ) [ 0 ] ; var routeData = { path : item . path , name : route . name , method : ! method || method === 'ALL' ? 'GET' : method } ; [ 'description' ] . forEach ( function ( k ) { if ( route [ k ] ) routeData [ k ] = route [ k ] ; } ) ; routes [ route . name ] = routeData ; } ) ; return { formats : [ 'json' ] , methods : routes } ; }
Specifications functions.
Specifications functions .