hedera-web/back/server/server.js

39 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2019-06-25 08:23:12 +00:00
// Copyright IBM Corp. 2016. All Rights Reserved.
// Node module: loopback-workspace
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
2020-06-29 11:31:48 +00:00
const loopback = require('loopback');
const boot = require('loopback-boot');
const i18n = require('i18n');
2019-06-25 08:23:12 +00:00
2020-06-29 11:31:48 +00:00
const app = module.exports = loopback();
i18n.configure({directory: `${__dirname}/../locales`});
app.use(i18n.init);
2019-06-25 08:23:12 +00:00
app.start = function() {
// start the web server
return app.listen(function() {
app.emit('started');
2020-06-29 11:31:48 +00:00
const baseUrl = app.get('url').replace(/\/$/, '');
2019-06-25 08:23:12 +00:00
console.log('Web server listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
2020-06-29 11:31:48 +00:00
const explorerPath = app.get('loopback-component-explorer').mountPath;
2019-06-25 08:23:12 +00:00
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();
});