2018-12-20 19:14:12 +00:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* DS103: Rewrite code to no longer use __guard__
|
|
|
|
* DS207: Consider shorter variations of null checks
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2018-12-20 19:14:14 +00:00
|
|
|
const logger = require('logger-sharelatex')
|
|
|
|
const settings = require('settings-sharelatex')
|
2014-08-15 09:50:36 +00:00
|
|
|
|
2018-12-20 19:14:14 +00:00
|
|
|
const Server = require('./app/js/server')
|
2014-08-15 10:35:22 +00:00
|
|
|
|
2018-12-20 19:14:14 +00:00
|
|
|
if (!module.parent) {
|
|
|
|
// Called directly
|
|
|
|
const port =
|
|
|
|
__guard__(
|
|
|
|
settings.internal != null ? settings.internal.chat : undefined,
|
|
|
|
x => x.port
|
|
|
|
) || 3010
|
|
|
|
const host =
|
|
|
|
__guard__(
|
|
|
|
settings.internal != null ? settings.internal.chat : undefined,
|
|
|
|
x1 => x1.host
|
|
|
|
) || 'localhost'
|
|
|
|
Server.server.listen(port, host, function(error) {
|
|
|
|
if (error != null) {
|
|
|
|
throw error
|
|
|
|
}
|
|
|
|
return logger.info(`Chat starting up, listening on ${host}:${port}`)
|
|
|
|
})
|
2018-12-20 19:14:12 +00:00
|
|
|
}
|
2014-08-15 10:35:22 +00:00
|
|
|
|
2018-12-20 19:14:14 +00:00
|
|
|
module.exports = Server.server
|
2018-12-20 19:14:12 +00:00
|
|
|
|
|
|
|
function __guard__(value, transform) {
|
2018-12-20 19:14:14 +00:00
|
|
|
return typeof value !== 'undefined' && value !== null
|
|
|
|
? transform(value)
|
|
|
|
: undefined
|
|
|
|
}
|