Skip to content

Commit

Permalink
Fix loopback explorer issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Berkeley Martinez authored and Berkeley Martinez committed Nov 6, 2015
1 parent f9f89ed commit 085fc2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"lodash": "^3.9.3",
"loopback": "^2.22.0",
"loopback-boot": "^2.13.0",
"loopback-component-explorer": "^2.1.1",
"loopback-component-passport": "https://github.com/FreeCodeCamp/loopback-component-passport.git#feature/flashfailure",
"loopback-connector-mongodb": "^1.10.0",
"lusca": "~1.3.0",
Expand Down Expand Up @@ -137,7 +138,7 @@
"envify": "^3.4.0",
"istanbul": "^0.4.0",
"jsonlint": "^1.6.2",
"loopback-explorer": "^2.0.2",
"loopback-component-explorer": "^2.1.1",
"loopback-testing": "^1.1.0",
"mocha": "~2.3.3",
"multiline": "~1.0.1",
Expand Down
15 changes: 7 additions & 8 deletions server/boot/explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@ module.exports = function mountLoopBackExplorer(app) {
}
var explorer;
try {
explorer = require('loopback-explorer');
explorer = require('loopback-component-explorer');
} catch (err) {
// Print the message only when the app was started via `app.listen()`.
// Do not print any message when the project is used as a component.
app.once('started', function() {
console.log(
'Run `npm install loopback-explorer` to enable the LoopBack explorer'
'Run `npm install loopback-component-explorer` to enable ' +
'the LoopBack explorer'
);
});
return;
}

var restApiRoot = app.get('restApiRoot');
var mountPath = '/explorer';

var explorerApp = explorer(app, { basePath: restApiRoot });
app.use('/explorer', explorerApp);
explorer(app, { basePath: restApiRoot, mountPath });
app.once('started', function() {
var baseUrl = app.get('url').replace(/\/$/, '');
// express 4.x (loopback 2.x) uses `mountpath`
// express 3.x (loopback 1.x) uses `route`
var explorerPath = explorerApp.mountpath || explorerApp.route;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);

console.log('Browse your REST API at %s%s', baseUrl, mountPath);
});
};

0 comments on commit 085fc2f

Please sign in to comment.