This is the main application script in the standard scaffolded application, as created by slc loopback.


1 - 3
: Require LoopBack modules and set up standard objects loopback, app, and boot.

 

6: Initialize (boot) the application.

7+: Start the application and web server.

var loopback = require('loopback');
var boot = require('loopback-boot');
var app = module.exports = loopback();
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname);
app.start = function() {
  // start the web server
  return app.listen(function() {
    app.emit('started');
    console.log('Web server listening at: %s', app.get('url'));
  });
};
// start the server if `$ node server.js`
if (require.main === module) {
  app.start();
}