Skip to content

Commit 085fc2f

Browse files
Berkeley MartinezBerkeley Martinez
authored andcommitted
Fix loopback explorer issue
1 parent f9f89ed commit 085fc2f

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"lodash": "^3.9.3",
8484
"loopback": "^2.22.0",
8585
"loopback-boot": "^2.13.0",
86+
"loopback-component-explorer": "^2.1.1",
8687
"loopback-component-passport": "https://github.com/FreeCodeCamp/loopback-component-passport.git#feature/flashfailure",
8788
"loopback-connector-mongodb": "^1.10.0",
8889
"lusca": "~1.3.0",
@@ -137,7 +138,7 @@
137138
"envify": "^3.4.0",
138139
"istanbul": "^0.4.0",
139140
"jsonlint": "^1.6.2",
140-
"loopback-explorer": "^2.0.2",
141+
"loopback-component-explorer": "^2.1.1",
141142
"loopback-testing": "^1.1.0",
142143
"mocha": "~2.3.3",
143144
"multiline": "~1.0.1",

server/boot/explorer.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,26 @@ module.exports = function mountLoopBackExplorer(app) {
44
}
55
var explorer;
66
try {
7-
explorer = require('loopback-explorer');
7+
explorer = require('loopback-component-explorer');
88
} catch (err) {
99
// Print the message only when the app was started via `app.listen()`.
1010
// Do not print any message when the project is used as a component.
1111
app.once('started', function() {
1212
console.log(
13-
'Run `npm install loopback-explorer` to enable the LoopBack explorer'
13+
'Run `npm install loopback-component-explorer` to enable ' +
14+
'the LoopBack explorer'
1415
);
1516
});
1617
return;
1718
}
1819

1920
var restApiRoot = app.get('restApiRoot');
21+
var mountPath = '/explorer';
2022

21-
var explorerApp = explorer(app, { basePath: restApiRoot });
22-
app.use('/explorer', explorerApp);
23+
explorer(app, { basePath: restApiRoot, mountPath });
2324
app.once('started', function() {
2425
var baseUrl = app.get('url').replace(/\/$/, '');
25-
// express 4.x (loopback 2.x) uses `mountpath`
26-
// express 3.x (loopback 1.x) uses `route`
27-
var explorerPath = explorerApp.mountpath || explorerApp.route;
28-
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
26+
27+
console.log('Browse your REST API at %s%s', baseUrl, mountPath);
2928
});
3029
};

0 commit comments

Comments
 (0)