<commit_before>// Authorizes the bot with Facebook

// / Locally-Hosted Setup
// Originally, we had to host the bot locally and pipe it through a hosted proxy (via ngrok) to allow it to connect via HTTPS to Facebook. 

// npm start: starts bot.js at the main folder
// ngrok http 3000: serves localhost:3000 at public_url
// `https://public_url.com/webhook`: Goes in developers.facebook.com > feedbackAI > Webhooks > Application > Edit Subscription > Callback url
// `https://public_url.com/webhook`: Goes in developers.facebook.com > feedbackAI > Webhooks > Page > Edit Subscription > Callback url
// `messages, messaging_postbacks`: Required messaging gpermissions in developers.facebook.com, also requires subscription to Feedbck page 

// / Cloud-Hosted Setup
// We have containerized and move our bot onto GAE, using a custom runtime and Google Compute Engine (hello bills!)
// docker build -t feedbackai: Build and tag the feedbackai bot.
// gcloud app deploy: Deploys bot to a project url; requires the gcloud SDK to be setup and intalled 
// gcloud app logs tail -s default: Dumps all the logs to the CLI from Google; great for monitoring it. 


// Webhook Router
let validator = require('express').Router();

// Imports
const facebook = require('../config/facebook');
let logger = require('winston');

// Facebook Authorization
validator.get('/', function(req, res) {
  console.log('\nAuthorizing bot with Facebook...');
  if (
    req.query['hub.mode'] === 'subscribe' &&
    req.query['hub.verify_token'] === facebook.verifyToken) {
    res.status(200).send(req.query['hub.challenge']);
    logger.info('Webhook validated!');
  } else {
    logger.error('Failed validation. Make sure the validation tokens match.');
    res.sendStatus(403);
  }
});

module.exports = validator;
<commit_msg>Winston logger instead of console.<commit_after>// Authorizes the bot with Facebook

// / Locally-Hosted Setup
// Originally, we had to host the bot locally and pipe it through a hosted proxy (via ngrok) to allow it to connect via HTTPS to Facebook. 

// npm start: starts bot.js at the main folder
// ngrok http 3000: serves localhost:3000 at public_url
// `https://public_url.com/webhook`: Goes in developers.facebook.com > feedbackAI > Webhooks > Application > Edit Subscription > Callback url
// `https://public_url.com/webhook`: Goes in developers.facebook.com > feedbackAI > Webhooks > Page > Edit Subscription > Callback url
// `messages, messaging_postbacks`: Required messaging gpermissions in developers.facebook.com, also requires subscription to Feedbck page 

// / Cloud-Hosted Setup
// We have containerized and move our bot onto GAE, using a custom runtime and Google Compute Engine (hello bills!)
// docker build -t feedbackai: Build and tag the feedbackai bot.
// gcloud app deploy: Deploys bot to a project url; requires the gcloud SDK to be setup and intalled 
// gcloud app logs tail -s default: Dumps all the logs to the CLI from Google; great for monitoring it. 


// Webhook Router
let validator = require('express').Router();

// Imports
const facebook = require('../config/facebook');
let logger = require('winston');

// Facebook Authorization
validator.get('/', function(req, res) {
  logger.info('\n Authorizing bot with Facebook...');
  if (
    req.query['hub.mode'] === 'subscribe' &&
    req.query['hub.verify_token'] === facebook.verifyToken) {
    res.status(200).send(req.query['hub.challenge']);
    logger.info('Webhook validated!');
  } else {
    logger.error('Failed validation. Make sure the validation tokens match.');
    res.sendStatus(403);
  }
});

module.exports = validator;

{'fraction_non_alphanumeric': 0.11561810154525386, 'fraction_numerical': 0.00772626931567329, 'mean_word_length': 3.972565157750343, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3854050', 'n_tokens_mistral': 1053, 'n_tokens_neox': 997, 'n_words': 391}