/* * Post new meta data for metrics. */ api.post('/metrics/v2/:id', handler((req, res) => { return Promise.map(plugins, plugin => { const reporter = new plugin.Reporter(config[plugin.config]); return reporter.ping() .then(() => reporter.report(_.merge({}, req.body, {instance: req.params.id}))) .then(() => log.info('Reported to %s', plugin.name)) .then(() => reporter.close()); }); }));
// Main logix Promise.fromNode(cb => { api.listen(config.LANDO_METRICS_PORT, cb); }) .then(() => { log.info('Listening on port: %s', config.LANDO_METRICS_PORT); });
// Start listening Promise.fromNode(cb => { api.listen(config.LANDO_API_PORT, cb); }) // Load our routes .then(() => { fs.readdirSync(path.join(__dirname, 'routes')).map(file => { require(`./routes/${file}`)(api, handler, {config, slack}); log.info('Loaded route %s', file); }); log.info('Listening on port: %s', config.LANDO_API_PORT); });
function debug() { var levels = ['debug', 'info']; var index = levels.indexOf(logger.transports.console.level); index = Math.max((index + 1) % levels.length, 0); logger.transports.console.level = levels[index]; logger.debug('Log mode: ' + levels[index]); }
// Handle user quit request const quitIntent = (app) => { logger.info(logObject('trivia', 'quitIntent', { info: 'Handling quit intent', rawInput: app.getRawInput() })); const ssmlResponse = new Ssml(); ssmlResponse.say(sprintf(getRandomPrompt(PROMPT_TYPES.END_PROMPTS), app.data.score, app.data.gameLength)); ssmlResponse.audio(getRandomAudio(AUDIO_TYPES.AUDIO_GAME_OUTRO), 'game ending'); app.tell(ssmlResponse.toString()); }
// Do some thing before saving data User.pre('save', function(next) { logger.debug('Starting saving user data'); next(); });
// Handle user play again NO response (already in play again context) const playAgainNoIntent = (app) => { logger.info(logObject('trivia', 'playAgainNoIntent', { info: 'Handling play again no intent', rawInput: app.getRawInput() })); const ssmlResponse = new Ssml(); ssmlResponse.say(getRandomPrompt(PROMPT_TYPES.QUIT_PROMPTS)); ssmlResponse.audio(getRandomAudio(AUDIO_TYPES.AUDIO_GAME_OUTRO), 'game ending'); app.tell(ssmlResponse.toString()); }
// Handle yes response to help request const helpYesIntent = (app) => { logger.info(logObject('trivia', 'helpYesIntent', { info: 'Handling help yes intent', rawInput: app.getRawInput() })); const ssmlResponse = new Ssml(); ssmlResponse.say(getRandomPrompt(PROMPT_TYPES.REPEAT_PROMPTS)); askQuestion(ssmlResponse, app.data.questionPrompt, app.data.selectedAnswers); }
/* * Post new meta data for metrics. */ api.post('/metrics/v2/:id', handler((req, res) => { return Promise.map(plugins, plugin => { const reporter = new plugin.Reporter(config[plugin.config]); return reporter.ping() .then(() => reporter.report(_.merge({}, req.body, {instance: req.params.id}))) .then(() => log.info('Reported to %s', plugin.name)) .then(() => reporter.close()); }); }));
// Main logix Promise.fromNode(cb => { api.listen(config.LANDO_METRICS_PORT, cb); }) .then(() => { log.info('Listening on port: %s', config.LANDO_METRICS_PORT); });