<commit_before>'use strict';

const {
    graphqlExpress,
    graphiqlExpress
} = require('graphql-server-express');

const bodyParser = require('body-parser');

const querySchema = require('../graph');

const Connector = require('../graph/storage/connector');
const {Substances} = require('../graph/storage/models');

module.exports = function* ({app, log}) {
    const baseQuerySchema = querySchema({log});

    app.use('/graphiql', graphiqlExpress({
        endpointURL: '/graph',
        query:
`{
  substances {
    name

    effects {
      name
    }
  }
}`,
    }));

    app.use('/', bodyParser.json(), (req, res, next) =>
        graphqlExpress({
            schema: baseQuerySchema.schema,
            rootValue: baseQuerySchema.root(req, res),
            context: {
                substances: new Substances({
                    connector: new Connector({log}),
                    log
                })
            }
        })(req, res, next)
    );
};<commit_msg>Use get for UI and post for data<commit_after>'use strict';

const {
    graphqlExpress,
    graphiqlExpress
} = require('graphql-server-express');

const bodyParser = require('body-parser');

const querySchema = require('../graph');

const Connector = require('../graph/storage/connector');
const {Substances} = require('../graph/storage/models');

module.exports = function* ({app, log}) {
    const baseQuerySchema = querySchema({log});

    app.get('/', graphiqlExpress({
        endpointURL: '/',
        query:
`{
  substances {
    name

    effects {
      name
    }
  }
}`,
    }));

    app.post('/', bodyParser.json(), (req, res, next) =>
        graphqlExpress({
            schema: baseQuerySchema.schema,
            rootValue: baseQuerySchema.root(req, res),
            context: {
                substances: new Substances({
                    connector: new Connector({log}),
                    log
                })
            }
        })(req, res, next)
    );
};
{'fraction_non_alphanumeric': 0.15220700152207, 'fraction_numerical': 0.0, 'mean_word_length': 2.110410094637224, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1844997', 'n_tokens_mistral': 570, 'n_tokens_neox': 553, 'n_words': 118}