<commit_before>const helpers = {
  /**
   * Express middleware to determine if the user is logged in
   * @param {Object} req
   * @param {Object} res
   * @param {Function} next
   */
  loggedIn(req, res, next) {
    if (req.user !== undefined) {
      next();
    } else {
      res.json({ status: 401, redirect: '/admin/login' });
    }
  },
  /**
   * Converts a String to a slug
   * @param {String} str
   * @returns {String}
   */
  slugify(str) {
    return str
      .toLowerCase()
      .replace(/^\s+|\s+$/g, '')   // Trim leading/trailing whitespace
      .replace(/[-\s]+/g, '-')     // Replace spaces with dashes
      .replace(/[^a-z0-9-]/g, '')  // Remove disallowed symbols
      .replace(/--+/g, '-');
  },
  /**
   * Reduces an array of objects to one object using the key value pair parameters
   * @param {Array} arr
   * @param {String} key
   * @param {String} value
   * @param {Object} start
   * @returns {Object}
   */
  reduceToObj(arr, key, value, start = {}) {
    return arr
      .reduce((prev, curr) =><commit_msg>:lock: Use isAuthenticated() method in LoggedIn middleware<commit_after>const helpers = {
  /**
   * Express middleware to determine if the user is logged in
   * @param {Object} req
   * @param {Object} res
   * @param {Function} next
   */
  loggedIn(req, res, next) {
    if (!req.isAuthenticated() || req.user !== undefined) {
      next();
    } else {
      res.json({ status: 401, redirect: '/admin/login' });
    }
  },
  /**
   * Converts a String to a slug
   * @param {String} str
   * @returns {String}
   */
  slugify(str) {
    return str
      .toLowerCase()
      .replace(/^\s+|\s+$/g, '')   // Trim leading/trailing whitespace
      .replace(/[-\s]+/g, '-')     // Replace spaces with dashes
      .replace(/[^a-z0-9-]/g, '')  // Remove disallowed symbols
      .replace(/--+/g, '-');
  },
  /**
   * Reduces an array of objects to one object using the key value pair parameters
   * @param {Array} arr
   * @param {String} key
   * @param {String} value
   * @param {Object} start
   * @returns {Object}
   */
  reduceToObj(arr, key, value, start = {}) {
    return arr
      .reduce((prev, curr) =>
{'fraction_non_alphanumeric': 0.17367205542725173, 'fraction_numerical': 0.004618937644341801, 'mean_word_length': 2.3220858895705523, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4191825', 'n_tokens_mistral': 737, 'n_tokens_neox': 730, 'n_words': 205}