<commit_before>
var tools = module.exports = exports = {},
    debug = require('debug')('turnkey');

tools.default_cfg = function() {
  var cfg = {
    // Required Options --------------------------------------------------------
    router: undefined,       /* Express JS Router */
    model: undefined,        /* Mongoose model */

    // Options with defaults ---------------------------------------------------
    hash_length: 256,
    hash_iterations: 12288,
    logger: console.log.bind(console),
    username_key: 'username',

    deserialize: function(id, cb) {
      cfg.model.findOne({ _id: id }, function(e, d) {
        d = (d && d.toJSON) ? d.toJSON({ getters: true }) : d;
        cb(e, d);
      });
    },

    serialize: function(u, cb) {
      return cb(null, String(u._id));
    },

    find_user: function(body, cb) {
      var uname = body && body.username && body.username.toLowerCase(),
          q = {};

      q[cfg.username_key] = uname;
      cfg.model.findOne(q, function(e, d) {
        d = (d && d.toJSON) ? d.toJSON({ getters: true }) : d;
        cb(e, d);
      });
    },

    // Optionals ---------------------------------------------------------------
    mailer: undefined     /* Mailer */
  };

  return cfg;
}<commit_msg>modularizing username key<commit_after>
var tools = module.exports = exports = {},
    debug = require('debug')('turnkey');

tools.default_cfg = function() {
  var cfg = {
    // Required Options --------------------------------------------------------
    router: undefined,       /* Express JS Router */
    model: undefined,        /* Mongoose model */

    // Options with defaults ---------------------------------------------------
    hash_length: 256,
    hash_iterations: 12288,
    logger: console.log.bind(console),
    username_key: 'username',

    deserialize: function(id, cb) {
      cfg.model.findOne({ _id: id }, function(e, d) {
        d = (d && d.toJSON) ? d.toJSON({ getters: true }) : d;
        cb(e, d);
      });
    },

    serialize: function(u, cb) {
      return cb(null, String(u._id));
    },

    find_user: function(body, cb) {
      var uname = body && body[cfg.username_key] &&
                  body[cfg.username_key].toLowerCase(),
          q = {};

      q[cfg.username_key] = uname;
      cfg.model.findOne(q, function(e, d) {
        d = (d && d.toJSON) ? d.toJSON({ getters: true }) : d;
        cb(e, d);
      });
    },

    // Optionals ---------------------------------------------------------------
    mailer: undefined     /* Mailer */
  };

  return cfg;
}
{'fraction_non_alphanumeric': 0.2733644859813084, 'fraction_numerical': 0.006230529595015576, 'mean_word_length': 1.4396961063627731, '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': '4458344', 'n_tokens_mistral': 767, 'n_tokens_neox': 738, 'n_words': 172}