<commit_before>import { Meteor } from "meteor/meteor";

// GraphQL
import { createApolloServer } from "meteor/apollo";
import { makeExecutableSchema } from "graphql-tools";
const cors = require("cors");
import { TodoList } from "/imports/models/TodoList.js";
import { typeDefs } from "/imports/api/schema";
import { resolvers } from "/imports/api/resolvers";

// Subscriptions
// Reference: https://www.apollographql.com/docs/graphql-subscriptions/meteor.html
import { WebApp } from "meteor/webapp";
import { SubscriptionServer } from "subscriptions-transport-ws";
import { execute, subscribe } from "graphql";

Meteor.startup(() => {
    if (TodoList.find().count() === 0) {
        TodoList.insert({
            _id: "123",
            task: "start engines",
            completed: true
        });
        TodoList.insert({
            _id: "456",
            task: "check wings",
            completed: false
        });
        TodoList.insert({
            _id: "789",
            task: "test flaps",
            completed: false
        });
    }
});

// Setup GraphQL
const schema = makeExecutableSchema({
    typeDefs,
    resolvers
});
createApolloServer(
    {
        schema
    },
    {
        configServer: graphQLServer => {
            if (Meteor.isDevelopment) {
                // Enable unrestricted cors only in development
                graphQLServer.use(cors());
            }
        }
    }
);

// Subscriptions
// Reference: https://www.apollographql.com/docs/graphql-subscriptions/setup.html
// and meteornl/ticker
new SubscriptionServer(
    {
        schema: schema,
        execute,
        subscribe
    },
    {
        server: WebApp.httpServer,
        path: "/subscriptions"
    }
);<commit_msg>Configuration for Hapi Apollo Server 2<commit_after>import { Meteor } from "meteor/meteor";

// GraphQL
const { ApolloServer, gql } = require('apollo-server-hapi');
const Hapi = require('hapi');

import { TodoList } from "/imports/models/TodoList.js";
import { typeDefs } from "/imports/api/schema";
import { resolvers } from "/imports/api/resolvers";

// Populate database with initial data
Meteor.startup(() => {
    if (TodoList.find().count() === 0) {
        TodoList.insert({
            _id: "123",
            task: "start engines",
            completed: true
        });
        TodoList.insert({
            _id: "456",
            task: "check wings",
            completed: false
        });
        TodoList.insert({
            _id: "789",
            task: "test flaps",
            completed: false
        });
    }
});

/**
 * Server startup
 * @constructor
 */
async function StartServer() {
  const server = new ApolloServer({
      typeDefs,
      resolvers,
      cors: true,
      context: async ({ request, response }) => {
      return {};
  }
  });

  const app = new Hapi.server({
    port: 4000
  });


  await server.applyMiddleware({
    app,
  });

  await server.installSubscriptionHandlers(app.listener);

  await app.start();
}

StartServer().catch(error => console.log(error));
{'fraction_non_alphanumeric': 0.13793103448275862, 'fraction_numerical': 0.008210180623973728, 'mean_word_length': 2.202944269190326, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6499102', 'n_tokens_mistral': 963, 'n_tokens_neox': 912, 'n_words': 203}