function startExpressApp () { return new Promise((resolve) => { logger.info('Starting App') const app = createApplication() createRouter(app) app.listen(config.server.port, () => { app.emit('ready') resolve(app) }) }) }
function connectMongoDB () { return new Promise((resolve, reject) => { logger.info('Connecting to MongoDB') // Use native Promise with mongoose mongoose.Promise = global.Promise let dbUrl = 'mongodb://' if (config.db.username) { dbUrl = `${dbUrl}${config.db.username}:${config.db.password}@` } const path = `${config.db.dbName}?ssl=${config.db.ssl || 'false'}` dbUrl = `${dbUrl}${config.db.host}:${config.db.port}/${path}` mongoose.connect(dbUrl) const db = mongoose.connection db.on('error', reject) db.once('open', () => { resolve(db) }) }) }
parseIncomingMessage (conversation, message) { const msg = {} const attachment = _.get(message, 'attachments[0]') if (attachment) { if (attachment.contentType.startsWith('image')) { msg.attachment = { type: 'picture', content: attachment.contentUrl } } else if (attachment.contentType.startsWith('video')) { msg.attachment = { type: 'video', content: attachment.contentUrl } } else { logger.warning('[Microsoft] No support for files of type: '.concat(attachment.contentType)) logger.info('[Microsoft] Defaulting to text') if (!message.text || message.text.length <= 0) { logger.error('[Microsoft] No text') throw new StopPipeline() } msg.attachment = { type: 'text', content: message.text } } } else { msg.attachment = { type: 'text', content: message.text } } return msg }
{ logger, progress }, )) { logger.info(output);
}, )) { logger.info(output);
}, )) { logger.info(output);
}, )) { logger.info(output);
}, )) { logger.info(output);
}, )) { logger.info(output);
{ logger, progress }, )) { logger.info(output);
}, )) { logger.info(output);
}, )) { logger.info(output);
}, )) { logger.info(output);
}, )) { logger.info(output);
}, )) { logger.info(output);