Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions templates/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,16 @@ app.use(loopback.methodOverride());
*/

// LoopBack REST interface
var apiPath = '/api';
app.use(apiPath, loopback.rest());
app.use(app.get('restApiRoot'), loopback.rest());

// API explorer (if present)
var explorerPath = '/explorer';
var explorerConfigured = false;
try {
var explorer = require('loopback-explorer');
app.use(explorerPath, explorer(app, { basePath: apiPath }));
explorerConfigured = true;
app.use('/explorer', explorer(app));
} catch(e){
// ignore errors, explorer stays disabled
console.log(
'Run `npm install loopback-explorer` to enable the LoopBack explorer'
);
}

/*
Expand Down Expand Up @@ -139,14 +137,8 @@ app.start = function() {
return require('http').createServer(app).listen(app.get('port'), app.get('host'),
function(){
var baseUrl = 'http://' + app.get('host') + ':' + app.get('port');
if (explorerConfigured) {
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
} else {
console.log(
'Run `npm install loopback-explorer` to enable the LoopBack explorer'
);
}
console.log('LoopBack server listening @ %s%s', baseUrl, '/');
app.emit('start');
}
);
}
Expand Down