<commit_before>'use strict';

module.exports = function(options) {
  var seneca = this;
  var plugin = 'badges';
  var version = '1.0';

  options = seneca.util.deepextend({
    prefix: '/api/'
  }, options);

  seneca.add({ role: plugin, cmd: 'listBadges'}, proxy);
  seneca.add({ role: plugin, cmd: 'getBadge'}, proxy);
  seneca.add({ role: plugin, cmd: 'sendBadgeApplication'}, proxy);
  seneca.add({ role: plugin, cmd: 'acceptBadge'}, proxy);
  seneca.add({ role: plugin, cmd: 'loadUserBadges'}, proxy);
  seneca.add({ role: plugin, cmd: 'loadBadgeCategories'}, proxy);

  function proxy(args, done) {
    var user = {};
    var zenHostname = args.req$.headers.host || '127.0.0.1:8000';
    if (args.req$.seneca.user) user = args.req$.seneca.user;
    seneca.act(seneca.util.argprops(
      {user: user, zenHostname: zenHostname},
      args, 
      {role: 'cd-badges'}
    ), done);
  }

  seneca.act('role:web', { use: { 
    prefix: options.prefix + version, 
    pin: { role: plugin, cmd: '*' },
    map: {
      'listBadges': { GET: true, alias: 'badges' },
      'getBadge': { GET: true, alias: 'badges/:slug' },
      'sendBadgeApplication': {POST: true, alias: 'badges/applications' },
      'acceptBadge': {POST: true, alias: 'badges/accept'},
      'loadUserBadges': {GET: true, alias: 'badges/user/:userId'},
      'loadBadgeCategories': {GET: true, alias: 'badge_categories'}
    }
  }});

  return {
      name: plugin
  }
};<commit_msg>Add locale param to proxy - badges<commit_after>'use strict';

module.exports = function(options) {
  var seneca = this;
  var plugin = 'badges';
  var version = '1.0';

  options = seneca.util.deepextend({
    prefix: '/api/'
  }, options);

  seneca.add({ role: plugin, cmd: 'listBadges'}, proxy);
  seneca.add({ role: plugin, cmd: 'getBadge'}, proxy);
  seneca.add({ role: plugin, cmd: 'sendBadgeApplication'}, proxy);
  seneca.add({ role: plugin, cmd: 'acceptBadge'}, proxy);
  seneca.add({ role: plugin, cmd: 'loadUserBadges'}, proxy);
  seneca.add({ role: plugin, cmd: 'loadBadgeCategories'}, proxy);

  function proxy(args, done) {
    var user = {};
    var zenHostname = args.req$.headers.host || '127.0.0.1:8000';
    var locality = (args.req$.cookies['NG_TRANSLATE_LANG_KEY'] && args.req$.cookies['NG_TRANSLATE_LANG_KEY'].replace(/\"/g, '')) || args.req$.headers['accept-language'];


    if (args.req$.seneca.user) user = args.req$.seneca.user;
    seneca.act(seneca.util.argprops(
      {user: user, zenHostname: zenHostname, locality: locality},
      args, 
      {role: 'cd-badges'}
    ), done);
  }

  seneca.act('role:web', { use: { 
    prefix: options.prefix + version, 
    pin: { role: plugin, cmd: '*' },
    map: {
      'listBadges': { GET: true, alias: 'badges' },
      'getBadge': { GET: true, alias: 'badges/:slug' },
      'sendBadgeApplication': {POST: true, alias: 'badges/applications' },
      'acceptBadge': {POST: true, alias: 'badges/accept'},
      'loadUserBadges': {GET: true, alias: 'badges/user/:userId'},
      'loadBadgeCategories': {GET: true, alias: 'badge_categories'}
    }
  }});

  return {
      name: plugin
  }
};
{'fraction_non_alphanumeric': 0.18808074335148992, 'fraction_numerical': 0.00768984299903877, 'mean_word_length': 3.5115606936416186, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4787783', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1103, 'n_words': 250}