<commit_before>import {
  GraphQLOptions,
  ServerOptionsFunction,
  HttpQueryError,
  runHttpQuery,
} from 'apollo-server-core';
import { Headers } from 'apollo-server-env';
import { Request, Response } from 'express';

type CloudFunctionGraphQLOptionsFunction = ServerOptionsFunction<
  [Request, Response]
>;

export function graphqlCloudFunction(
  options: GraphQLOptions | CloudFunctionGraphQLOptionsFunction,
): any {
  if (!options) {
    throw new Error('Apollo Server requires options.');
  }

  if (arguments.length > 1) {
    throw new Error(
      `Apollo Server expects exactly one argument, got ${arguments.length}`,
    );
  }

  const graphqlHandler: any = (req: Request, res: Response): void => {
    const hasPostBody = req.body && Object.keys(req.body).length > 0;
    if (req.method === 'POST' && !hasPostBody) {
      res.status(500).send('POST body missing.');
      return;<commit_msg>Export `CloudFunctionGraphQLOptionsFunction` type, like other integrations.<commit_after>import {
  GraphQLOptions,
  ServerOptionsFunction,
  HttpQueryError,
  runHttpQuery,
} from 'apollo-server-core';
import { Headers } from 'apollo-server-env';
import { Request, Response } from 'express';

export type CloudFunctionGraphQLOptionsFunction = ServerOptionsFunction<
  [Request, Response]
>;

export function graphqlCloudFunction(
  options: GraphQLOptions | CloudFunctionGraphQLOptionsFunction,
): any {
  if (!options) {
    throw new Error('Apollo Server requires options.');
  }

  if (arguments.length > 1) {
    throw new Error(
      `Apollo Server expects exactly one argument, got ${arguments.length}`,
    );
  }

  const graphqlHandler: any = (req: Request, res: Response): void => {
    const hasPostBody = req.body && Object.keys(req.body).length > 0;
    if (req.method === 'POST' && !hasPostBody) {
      res.status(500).send('POST body missing.');
      return;
{'fraction_non_alphanumeric': 0.12294647588765235, 'fraction_numerical': 0.005299417064122946, 'mean_word_length': 4.273743016759776, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '1563451', 'n_tokens_mistral': 571, 'n_tokens_neox': 548, 'n_words': 147}