<commit_before>'use strict';

var when = require('when');

/**
 * Processes a inbound Spark API webhook.
 * @function
 * @private
 * @param {Object} flint - The flint object this function applies to.
 * @returns {Function}
 * Function that can be used for Express and Express-like webserver routes.
 *
 */
function Webhook(flint) {

  return function(req, res, next) {

    // emit webhook event (mostly here for debugging...)
    flint.emit('webhook', req[flint.options.webhookRequestJSONLocation]);

    // if "res" is passed to function...
    if(typeof res !== 'undefined') {
      res.status(200);
      res.send('OK');
    }

    if(typeof next === 'function') {
      next();
    }

    // get webhook header to determine if security is enabled
    var sig = req.headers['x-spark-signature'] || false;
    var body = req[flint.options.webhookRequestJSONLocation] || false;

    if(!body){
      return when(true);
    }<commit_msg>Updated handling of next in returned function<commit_after>'use strict';

var when = require('when');

/**
 * Processes a inbound Spark API webhook.
 * @function
 * @private
 * @param {Object} flint - The flint object this function applies to.
 * @returns {Function}
 * Function that can be used for Express and Express-like webserver routes.
 *
 */
function Webhook(flint) {

  return function(req, res) {

    // emit webhook event (mostly here for debugging...)
    flint.emit('webhook', req[flint.options.webhookRequestJSONLocation]);

    // if "res" is passed to function...
    if(typeof res !== 'undefined') {
      res.status(200);
      res.send('OK');
    }

    // get webhook header to determine if security is enabled
    var sig = req.headers['x-spark-signature'] || false;
    var body = req[flint.options.webhookRequestJSONLocation] || false;

    if(!body){
      return when(true);
    }
{'fraction_non_alphanumeric': 0.1339479392624729, 'fraction_numerical': 0.0032537960954446853, 'mean_word_length': 3.1367713004484306, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '55480', 'n_tokens_mistral': 560, 'n_tokens_neox': 535, 'n_words': 173}