<commit_before>/**
 * Created by <NAME> on 14-Aug-17.
 */

'use strict';

const DI = require('../di');

/**
 * @param ctx {Object}
 * @param original {Function}
 * @returns {Function}
 */
const diResolver = function(ctx, original) {
  /** @param diConfig {Function|String|Object<{controller: string, action: string, [params]: Array}>} */
  return function(diConfig) {
    switch (typeof diConfig) {
      case 'string':
        original.call(ctx, ctx.context.di.resolve(diConfig));
        break;
      case 'object': // array
        const { controller, action, params } = diConfig;
        const dependency = ctx.context.di.resolve(controller);
        original.call(ctx, async (ctx, next) => {
          if (next) {
            await dependency[action](ctx, next, params);
          } else {
            await dependency[action](ctx, params);
          }
        });
        break;
      default: // function
        original.call(ctx, diConfig);
    }
    return ctx;
  };
};

/**
 * @param app {Object}
 * @param ctx {Object}
 * @param original {Function}
 * @returns {Function}
 */
const diRouterResolver = function(app, ctx, original) {
  /**
   * path {string}
   * @param diConfig {Function|String|Object<{controller: string, action: string, [params]: Array}>}
   */
  return function(path, diConfig) {
    switch (typeof diConfig) {
      case 'string':
        original.call(ctx, path, app.context.di.resolve(diConfig));
        break;
      case 'object': // array
        const { controller, action, params } = diConfig;
        const dependency = app.context.di.resolve(controller);
        original.call(ctx, path, async (ctx, next) => {
          if (next) {
            await dependency[action](ctx, next, params);
          } else {
            await dependency[action](ctx, params);
          }
        });
        break;
      default: // function
        original.call(ctx, path, diConfig);
    }
    return ctx;
  };
};

/**
 *
 * @param app<commit_msg>factory fix;<commit_after>/**
 * Created by <NAME> on 14-Aug-17.
 */

'use strict';

const DI = require('../di');

/**
 * @param ctx {Object}
 * @param original {Function}
 * @returns {Function}
 */
const diResolver = function(ctx, original) {
  /** @param diConfig {Function|String|Object<{controller: string, action: string, [params]: Array}>} */
  return function(diConfig) {
    switch (typeof diConfig) {
      case 'string':
        original.call(ctx, ctx.context.di.resolve(diConfig));
        break;
      case 'object':
        const { controller, action, params } = diConfig;
        original.call(ctx, async (ctx, next) => {
          const dependency = ctx.context.di.resolve(controller);
          if (next) {
            await dependency[action](ctx, next, params);
          } else {
            await dependency[action](ctx, params);
          }
        });
        break;
      default: // function
        original.call(ctx, diConfig);
    }
    return ctx;
  };
};

/**
 * @param app {Object}
 * @param ctx {Object}
 * @param original {Function}
 * @returns {Function}
 */
const diRouterResolver = function(app, ctx, original) {
  /**
   * path {string}
   * @param diConfig {Function|String|Object<{controller: string, action: string, [params]: Array}>}
   */
  return function(path, diConfig) {
    switch (typeof diConfig) {
      case 'string':
        original.call(ctx, path, app.context.di.resolve(diConfig));
        break;
      case 'object':
        const { controller, action, params } = diConfig;
        original.call(ctx, path, async (ctx, next) => {
          const dependency = app.context.di.resolve(controller);
          if (next) {
            await dependency[action](ctx, next, params);
          } else {
            await dependency[action](ctx, params);
          }
        });
        break;
      default: // function
        original.call(ctx, path, diConfig);
    }
    return ctx;
  };
};

/**
 *
 * @param app
{'fraction_non_alphanumeric': 0.15120711562897077, 'fraction_numerical': 0.0020330368487928843, 'mean_word_length': 2.358361774744027, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '7182397', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1153, 'n_words': 292}