Code coverage report for server/boot/explorer.js

Statements: 56.25% (9 / 16)      Branches: 25% (1 / 4)      Functions: 33.33% (1 / 3)      Lines: 56.25% (9 / 16)      Ignored: none     

All files » server/boot/ » explorer.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 311 1     1 1 1                       1   1 1 1                
module.exports = function mountLoopBackExplorer(app) {
  Iif (process.env.NODE_ENV === 'production') {
    return;
  }
  var explorer;
  try {
    explorer = require('loopback-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'
      );
    });
    return;
  }
 
  var restApiRoot = app.get('restApiRoot');
 
  var explorerApp = explorer(app, { basePath: restApiRoot });
  app.use('/explorer', explorerApp);
  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);
  });
};