<commit_before>import joi from 'joi';

const schema = joi.object().keys({
  ssl: joi
    .object()
    .keys({
      letsEncryptEmail: joi.string().trim(),
      crt: joi.string().trim(),
      key: joi.string().trim(),
      forceSSL: joi.bool()
    })
    .and('crt', 'key')
    .without('letsEncryptEmail', ['crt', 'key'])
    .or('letsEncryptEmail', 'crt', 'forceSSL'),
  domains: joi.string().required(),
  nginxServerConfig: joi.string(),
  nginxLocationConfig: joi.string(),
  clientUploadLimit: joi.string(),
  shared: joi.object().keys({
    clientUploadLimit: joi.alternatives().try(joi.number(), joi.string()),
    httpPort: joi.number(),
    httpsPort: joi.number(),
    nginxConfig: joi.string(),
    env: joi
      .object()
      .pattern(/[\s\S]*/, [joi.string(), joi.number(), joi.boolean()]),
    envLetsEncrypt: joi
      .object()
      .keys({
        ACME_CA_URI: joi.string().regex(new RegExp('^(http|https)://', 'i')),
        DEBUG: joi.boolean(),
        NGINX_PROXY_CONTAINER: joi.string()
      })
      .pattern(/[\s\S]*/, [joi.string(), joi.number(), joi.boolean()])
  })
});

export default function(config, {
  addDepreciation,
  combineErrorDetails,
  VALIDATE_OPTIONS,
  addLocation
}) {
  let details = [];
  details = combineErrorDetails(
    details,
    joi.validate(config.proxy, schema, VALIDATE_OPTIONS)
  );
  if (
    config.app && config.app.env && config.app.env.PORT
  ) {
    details.push({
      message: 'app.env.PORT is ignored when using the reverse proxy',
      path: ''
    });
  }

  if (config.proxy.shared && config.proxy.shared.clientUploadLimit) {
    details = addDepreciation(
      details,
      'shared.clientUploadLimit',
      'Use proxy.clientUploadLimit instead',
      'https://git.io/vN5tn'
    );
  }

  return addLocation(details, 'proxy');
}
<commit_msg>Do not show proxy's env.PORT warning when port is set to 80 This allows plugins to set a default port during prepareConfig.<commit_after>import joi from 'joi';

const schema = joi.object().keys({
  ssl: joi
    .object()
    .keys({
      letsEncryptEmail: joi.string().trim(),
      crt: joi.string().trim(),
      key: joi.string().trim(),
      forceSSL: joi.bool()
    })
    .and('crt', 'key')
    .without('letsEncryptEmail', ['crt', 'key'])
    .or('letsEncryptEmail', 'crt', 'forceSSL'),
  domains: joi.string().required(),
  nginxServerConfig: joi.string(),
  nginxLocationConfig: joi.string(),
  clientUploadLimit: joi.string(),
  shared: joi.object().keys({
    clientUploadLimit: joi.alternatives().try(joi.number(), joi.string()),
    httpPort: joi.number(),
    httpsPort: joi.number(),
    nginxConfig: joi.string(),
    env: joi
      .object()
      .pattern(/[\s\S]*/, [joi.string(), joi.number(), joi.boolean()]),
    envLetsEncrypt: joi
      .object()
      .keys({
        ACME_CA_URI: joi.string().regex(new RegExp('^(http|https)://', 'i')),
        DEBUG: joi.boolean(),
        NGINX_PROXY_CONTAINER: joi.string()
      })
      .pattern(/[\s\S]*/, [joi.string(), joi.number(), joi.boolean()])
  })
});

export default function(config, {
  addDepreciation,
  combineErrorDetails,
  VALIDATE_OPTIONS,
  addLocation
}) {
  let details = [];
  details = combineErrorDetails(
    details,
    joi.validate(config.proxy, schema, VALIDATE_OPTIONS)
  );
  if (
    config.app && config.app.env && config.app.env.PORT !== 80
  ) {
    details.push({
      message: 'app.env.PORT is ignored when using the reverse proxy',
      path: ''
    });
  }

  if (config.proxy.shared && config.proxy.shared.clientUploadLimit) {
    details = addDepreciation(
      details,
      'shared.clientUploadLimit',
      'Use proxy.clientUploadLimit instead',
      'https://git.io/vN5tn'
    );
  }

  return addLocation(details, 'proxy');
}

{'fraction_non_alphanumeric': 0.17767170511800584, 'fraction_numerical': 0.0015910898965791568, 'mean_word_length': 3.038543897216274, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5874663', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1303, 'n_words': 248}