<commit_before>'use strict';

const path = require('path');
const createTemplates = require('./create-templates');

module.exports = {
  modifiers: {
    content: []
  },
  render: function() {
    return createTemplates(this.modifiers).then(data => {
      this.templates = data.templates;
      return (req, res, next) => {
        let target = this.templates[req.url];
        if (target) {
          res.sendFile(path.join(__dirname, '..', target));
        } else {
          next();
        }
      };
    });
  },
  addModifier: function() {
    let target;
    let modifier;
    if (typeof arguments[0] === 'object') {
      target = arguments[0].target;
      modifier = arguments[0].modifier;
    } else {
      target = arguments[0];
      modifier = arguments[1];
    }

    if (!this.modifiers[target]) throw new Error('Event does not exist.');
    if (typeof modifier !== 'function') throw new Error('Not a function.');
    this.modifiers[target].push(modifier);
  }
};<commit_msg>added api for getting content structure<commit_after>'use strict';

const path = require('path');
const createTemplates = require('./create-templates');

module.exports = {
  modifiers: {
    content: []
  },
  templates: {},
  render: function() {
    return createTemplates(this.modifiers).then(data => {
      this.templates = data.templates;
      this.api.structure = data.structure;
      return (req, res, next) => {
        let target = this.templates[req.url];
        if (target) {
          res.sendFile(path.join(__dirname, '..', target));
        } else {
          next();
        }
      };
    });
  },
  addModifier: function() {
    let target;
    let modifier;
    if (typeof arguments[0] === 'object') {
      target = arguments[0].target;
      modifier = arguments[0].modifier;
    } else {
      target = arguments[0];
      modifier = arguments[1];
    }

    if (!this.modifiers[target]) throw new Error('Event does not exist.');
    if (typeof modifier !== 'function') throw new Error('Not a function.');
    this.modifiers[target].push(modifier);
  },
  api: {
    structure: {},
    getContentStructure: function(key) {
      return this.structure[key];
    }
  }
};
{'fraction_non_alphanumeric': 0.1589041095890411, 'fraction_numerical': 0.0045662100456621, 'mean_word_length': 2.6155115511551155, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6287969', 'n_tokens_mistral': 653, 'n_tokens_neox': 652, 'n_words': 148}