<commit_before>'use strict'

const express = require('express');
const bodyParser = require('body-parser');
const request = require('request');
const xhub = require('express-x-hub');
const app = express();

const PORT = process.env.PORT || 8080;

app.use(xhub({algorithm: 'sha1', secret: process.env.APP_SECRET }));
app.use(bodyParser.json());

var received_updates = [];

app.get('/', function(req, res) {
  res.send(JSON.stringify(received_updates, null, 2));
});

app.get('/webhooks', function(req, res) {
  if (req.param('hub.mode') != 'subscribe'
      || req.param('hub.verify_token') != process.env.VERIFY_TOKEN) {
    res.sendStatus(401);
    return;
  }

  res.send(req.param('hub.challenge'));
});

app.post('/webhooks', function(req, res) {
  if (!req.isXHubValid()) {
    console.log('Received webhooks update with invalid X-Hub-Signature');
    res.sendStatus(401);
    return;
  }
  console.log(JSON.stringify(req.body, null, 2));
  received_updates.unshift(req.body);
  res.sendStatus(200);<commit_msg>prettyprint<commit_after>'use strict'

const express = require('express');
const bodyParser = require('body-parser');
const request = require('request');
const xhub = require('express-x-hub');
const app = express();

const PORT = process.env.PORT || 8080;

app.use(xhub({algorithm: 'sha1', secret: process.env.APP_SECRET }));
app.use(bodyParser.json());

var received_updates = [];

app.get('/', function(req, res) {
  res.send(
    '<pre>' + JSON.stringify(received_updates, null, 2) + '</pre>',
  );
});

app.get('/webhooks', function(req, res) {
  if (req.param('hub.mode') != 'subscribe'
      || req.param('hub.verify_token') != process.env.VERIFY_TOKEN) {
    res.sendStatus(401);
    return;
  }

  res.send(req.param('hub.challenge'));
});

app.post('/webhooks', function(req, res) {
  if (!req.isXHubValid()) {
    console.log('Received webhooks update with invalid X-Hub-Signature');
    res.sendStatus(401);
    return;
  }
  console.log(JSON.stringify(req.body, null, 2));
  received_updates.unshift(req.body);
  res.sendStatus(200);
{'fraction_non_alphanumeric': 0.19398642095053345, 'fraction_numerical': 0.015518913676042677, 'mean_word_length': 4.667582417582418, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1802583', 'n_tokens_mistral': 734, 'n_tokens_neox': 714, 'n_words': 128}