<|start_filename|>packages/api/cloud-functions/webpack.config.js<|end_filename|>
const path = require('path');

module.exports = {
  target: 'node',
  mode: 'production',
  entry: {
    main: './cloud-functions/index.ts',
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: ['ts-loader', path.join(__dirname, './add-entities.js')],
        exclude: /node_modules/,
      },
    ],
  },
  resolve: {
    extensions: ['.tsx', '.ts', '.js', '.jsx', '.json'],
  },
  devtool: 'inline-source-map',
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, './dist'),
    libraryTarget: 'commonjs',
  },
  externals: {
    'firebase-admin': 'firebase-admin',
    'firebase-functions': 'firebase-functions',
    'cache-manager': 'cache-manager',
  },
  optimization: {
    minimize: false,
  },
};


<|start_filename|>packages/api/cloud-functions/add-entities.js<|end_filename|>
const glob = require('glob');
const path = require('path');

/**
 * Looks for all *.entity.{js,ts} files and generates import statements for them. After all the import statements,
 * adds an inline const definition for all the imported names which can then be used by the script.
 * @returns {string}
 */
function getEntityImports() {
  const imports = glob
    .sync(path.join(__dirname, '../src/**/*.entity.{js,ts}'))
    .reduce(
      (acc, entityPath) => {
        const { names, importsString } = acc;
        const [entityNameRaw] = entityPath.match(
          /[^/]+(?=\.entity\.(?:js|ts)$)/,
        );
        const nameParts = entityNameRaw.split('-');
        const entityName = nameParts
          .map((name) => name[0].toUpperCase() + name.slice(1))
          .join('');
        return {
          names: [...names, entityName],
          importsString: `${importsString}import * as ${entityName} from '${entityPath}';\n`,
        };
      },
      { names: [], importsString: '' },
    );
  return `${imports.importsString}\nconst dbEntities = [${imports.names.join(
    ', ',
  )}];`;
}

module.exports = function addEntityImports(source) {
  return source.replace('// import-all-entities', getEntityImports());
};


<|start_filename|>packages/api/test/jest.json<|end_filename|>
{
  "moduleFileExtensions": ["js", "json", "ts"],
  "rootDir": "../",
  "testEnvironment": "node",
  "testRegex": ["app.spec.ts$", "test.ts$"],
  "testTimeout": 120000,
  "verbose": true,
  "collectCoverage": true,
  "cacheDirectory": ".jest-cache",
  "coveragePathIgnorePatterns": [
    "node_modules",
    "migration",
    "entity.ts",
    "module.ts",
    "dto.ts",
    "ormconfig.ts",
    "spec.ts",
    "test",
    "docs",
    "config"
  ],
  "transform": {
    "\\.ts$": "ts-jest"
  }
}
