Skip to content

Commit c990164

Browse files
author
David Cheung
committed
Updating scaffolding of Loopback Explorer
- Using server.js in replace of bootscripts to launch explorer - Update `package.json` to use `loopback-component-explorer` - Remove bootscripts for REST Explorer - Add `server/component-config.json` - Add REST paths routes in `middleware.json`
1 parent 830391a commit c990164

File tree

6 files changed

+13
-30
lines changed

6 files changed

+13
-30
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
"errorhandler": "^1.1.1",
1313
"loopback": "^2.14.0",
1414
"loopback-boot": "^2.6.5",
15+
"loopback-component-explorer": "^2.1.0",
1516
"loopback-datasource-juggler": "^2.0.0",
1617
"serve-favicon": "^2.0.1"
1718
},
18-
"optionalDependencies": {
19-
"loopback-explorer": "^1.1.0"
20-
},
2119
"devDependencies": {
2220
"jshint": "^2.8.0"
2321
}

server/boot/explorer.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

server/boot/rest-api.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

server/component-config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"loopback-component-explorer": {
3+
"mountPath": "/explorer"
4+
}
5+
}

server/middleware.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
"parse": {
1313
},
1414
"routes": {
15+
"loopback#rest": {
16+
"paths": ["${restApiRoot}"]
17+
}
1518
},
1619
"files": {
1720
},

server/server.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ app.start = function(httpOnly) {
2828
var baseUrl = (httpOnly? 'http://' : 'https://') + app.get('host') + ':' + app.get('port');
2929
app.emit('started', baseUrl);
3030
console.log('LoopBack server listening @ %s%s', baseUrl, '/');
31+
if (app.get('loopback-component-explorer')) {
32+
var explorerPath = app.get('loopback-component-explorer').mountPath;
33+
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
34+
}
3135
});
3236
return server;
3337
};

0 commit comments

Comments
 (0)