Skip to content

Commit

Permalink
Stores built routes under resource path, uses basePath as mountPath.
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Livingston committed Sep 24, 2014
1 parent e429278 commit 8e6156a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/expressroutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function expressroutes(router, options) {
basepath = url.parse(resource.api.basePath);
mountpath = basepath.pathname;
resourcepath = utils.prefix(resource.api.resourcePath, '/');
routes = options.routes[mountpath];
routes = options.routes[resourcepath];

routes && router.get(docspath + resourcepath, function (req, res) {
res.json(resource.api);
Expand Down
9 changes: 4 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,18 @@ function swaggerize(options) {
routes = {};

options.resources.forEach(function (resource) {
var opts, basepath, mountpath;
var opts;

basepath = url.parse(resource.api.basePath);
mountpath = basepath.pathname;
routes[mountpath] = [];
resource.api.resourcePath = utils.prefix(resource.api.resourcePath, '/');
routes[resource.api.resourcePath] = [];

opts = {
api: resource.api,
handlers: resource.handlers,
basedir: options.basedir
};

Array.prototype.push.apply(routes[mountpath], builder(opts));
Array.prototype.push.apply(routes[resource.api.resourcePath], builder(opts));
});

options.routes = routes;
Expand Down

0 comments on commit 8e6156a

Please sign in to comment.