salix/services/client/server/server.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-11-09 12:12:59 +00:00
'use strict';
var loopback = require('loopback');
var boot = require('loopback-boot');
var app = module.exports = loopback();
2017-03-31 10:12:46 +00:00
/*i18n*/
var i18n = require("i18n");
i18n.configure({
directory: __dirname + '/i18n',
defaultLocale: "es"
});
/* Prueba i18n */
app.get('/prueba', function (req,res){
i18n.setLocale(req.get('Accept-Language').substring(0,2));
res.send(i18n.__("Hello"));
});
2016-11-09 12:12:59 +00:00
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();
});