overleaf/services/chat/app.js
Eric Mc Sween 0a12c47b35 Merge pull request #10815 from overleaf/em-esm-chat
Move chat service to ES modules

GitOrigin-RevId: c08ae8328b8f3b539e6cfe052834b84bb3756330
2022-12-14 09:03:03 +00:00

22 lines
655 B
JavaScript

import logger from '@overleaf/logger'
import settings from '@overleaf/settings'
import { mongoClient } from './app/js/mongodb.js'
import { server } from './app/js/server.js'
const port = settings.internal.chat.port
const host = settings.internal.chat.host
mongoClient
.connect()
.then(() => {
server.listen(port, host, function (err) {
if (err) {
logger.fatal({ err }, `Cannot bind to ${host}:${port}. Exiting.`)
process.exit(1)
}
logger.debug(`Chat starting up, listening on ${host}:${port}`)
})
})
.catch(err => {
logger.fatal({ err }, 'Cannot connect to mongo. Exiting.')
process.exit(1)
})