LoopBack 3 has reached end of life. We are no longer accepting pull requests or providing support for community users. The only exception is fixes for critical bugs and security vulnerabilities provided as part of support for IBM API Connect customers. We urge all LoopBack 3 users to migrate their applications to LoopBack 4 as soon as possible. Learn more about LoopBack's long term support policy.

server.js

Edit this page
Page Contents

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

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

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

4: Start the web server.

7: Emit the ‘started’ event.

10 - 13: Start API Explorer.

18: Initialize (boot) the application.


AltStyle によって変換されたページ (->オリジナル) /