<commit_before>import jwt, { VerifyOptions } from 'jsonwebtoken';
import jwksClient from 'jwks-rsa';
import { getSession } from '@auth0/nextjs-auth0';
import Cors from 'cors';
import redactedDirective from '../../api/directives/redactedDirective';
import authDirective from '../../api/directives/authDirective';
import schema from '../../api-client/schema';
import { createServer } from '@graphql-yoga/node';
import { createInMemoryCache, useResponseCache } from '@envelop/response-cache';
import { useSentry } from '@envelop/sentry';
import Redis from 'ioredis';
import { createRedisCache } from '@envelop/response-cache-redis';

const setupCache = () => {
  if (
    (process.env.NODE_ENV === 'development' ||
      process.env.NODE_ENV === 'test') &&
    process.env.ENABLE_REDIS_CACHE !== 'true'
  ) {
    return createInMemoryCache();
  }

  const redis = new Redis({
    host: process.env.REDIS_URI,
    username: 'default',
    port: 11345,
    password: <PASSWORD>,
  });

  return createRedisCache({ redis });
};

const cache = setupCache();

const client = jwksClient({
  jwksUri: `${process.env.AUTH0_ISSUER_BASE_URL}.well-known/jwks.json`,
});

function getKey(header, cb) {
  client.getSigningKey(header.kid, function (err, key) {<commit_msg>fix: simplify redis enable logic<commit_after>import jwt, { VerifyOptions } from 'jsonwebtoken';
import jwksClient from 'jwks-rsa';
import { getSession } from '@auth0/nextjs-auth0';
import Cors from 'cors';
import redactedDirective from '../../api/directives/redactedDirective';
import authDirective from '../../api/directives/authDirective';
import schema from '../../api-client/schema';
import { createServer } from '@graphql-yoga/node';
import { createInMemoryCache, useResponseCache } from '@envelop/response-cache';
import { useSentry } from '@envelop/sentry';
import Redis from 'ioredis';
import { createRedisCache } from '@envelop/response-cache-redis';

const setupCache = () => {
  if (process.env.ENABLE_REDIS_CACHE !== 'true') {
    return createInMemoryCache();
  }

  const redis = new Redis({
    host: process.env.REDIS_URI,
    username: 'default',
    port: 11345,
    password: <PASSWORD>,
  });

  return createRedisCache({ redis });
};

const cache = setupCache();

const client = jwksClient({
  jwksUri: `${process.env.AUTH0_ISSUER_BASE_URL}.well-known/jwks.json`,
});

function getKey(header, cb) {
  client.getSigningKey(header.kid, function (err, key) {
{'fraction_non_alphanumeric': 0.15254934210526316, 'fraction_numerical': 0.006578947368421052, 'mean_word_length': 4.567505720823799, 'pattern_counts': {'":': 0, '<': 5, '<?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': '746483', 'n_tokens_mistral': 811, 'n_tokens_neox': 798, 'n_words': 182}