Serving all routes from a specific folder (using PODS)

@mmiklo - Oh, that’s much better. I’m not sure you need resolveOther since the only things in the routes folder are routes, controllers, and templates. I’m not sure if name should be updated. Here’s my variation of your code:

  Resolver: Resolver.extend({
    /**
     * Extend the resolver to allow routes to be within the routes directory.
     */
    adjustRoute(parsedName, type) {
      parsedName.fullNameWithoutType = 'routes/' + parsedName.fullNameWithoutType;
      parsedName.fullName = type + ':' + parsedName.fullNameWithoutType;
      return this;
    },
    resolveRoute(parsedName) {
      return this._super(parsedName) || this.adjustRoute(parsedName, 'route')._super(parsedName);
    },
    resolveTemplate(parsedName) {
      return this._super(parsedName) || this.adjustRoute(parsedName, 'template')._super(parsedName);
    },
    resolveController(parsedName) {
      return this._super(parsedName) || this.adjustRoute(parsedName, 'controller')._super(parsedName);
    },
  }),

You didn’t mention it, but this also supports routes nested within the routes directory. Again, thanks!

2 Likes