Skip to content

Commit

Permalink
Merge pull request #31 from tlivings/v2.0.0
Browse files Browse the repository at this point in the history
Stores built routes under resource path, uses basePath as mountPath.
  • Loading branch information
grawk committed Sep 24, 2014
2 parents 8d536ab + 8e6156a commit 6070fc2
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
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
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 6070fc2

Please sign in to comment.