<commit_before>const SwaggerExpress = require('swagger-express-mw');
const SwaggerUi = require('swagger-tools/middleware/swagger-ui');
const app = require('express')();
const mongoose = require('mongoose');
const fs = require('fs');
const util = require('serverutils');
const configFile = util.config.getConfiguration();

module.exports = app;

const config = {
  appRoot: __dirname, // required config
};

SwaggerExpress.create(config, (err, swaggerExpress) => {
  if (err) {
    throw new Error(`couldn't create swaggerExpress server, err: ${err}`);
  }

  console.log('server started');

  // add swagger-ui
  app.use(SwaggerUi(swaggerExpress.runner.swagger));

  // install middleware
  swaggerExpress.register(app);

  // Read the certificates
  // const ca = [fs.readFileSync(configFile.dbCertPath + 'CAChain.pem')];
  // const key = fs.readFileSync(configFile.dbCertPath + 'Mongodb.pem');

  // Connect to mongoDB via mongoose
  // const user = configFile['mongo.user'];
  // const pass = configFile['mongo.pass'];
  const db = configFile['mongo.dbname'];
  const url = configFile['mongo.url'] + `/${db}`;

  const options = {
    // user,
    // pass,
    name: db,
    // auth: {
    //   authSource: 'admin',
    // },
    // server: {<commit_msg>added CORS headers for all requests<commit_after>const SwaggerExpress = require('swagger-express-mw');
const SwaggerUi = require('swagger-tools/middleware/swagger-ui');
const app = require('express')();
const mongoose = require('mongoose');
const fs = require('fs');
const util = require('serverutils');
const configFile = util.config.getConfiguration();

module.exports = app;

const config = {
  appRoot: __dirname, // required config
};

SwaggerExpress.create(config, (err, swaggerExpress) => {
  if (err) {
    throw new Error(`couldn't create swaggerExpress server, err: ${err}`);
  }

  console.log('server started');

  // add swagger-ui
  app.use(SwaggerUi(swaggerExpress.runner.swagger));

  // allow CORS
  app.use((req, res, next) => {
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
    res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');

    next();
  });

  // install middleware
  swaggerExpress.register(app);

  // Read the certificates
  // const ca = [fs.readFileSync(configFile.dbCertPath + 'CAChain.pem')];
  // const key = fs.readFileSync(configFile.dbCertPath + 'Mongodb.pem');

  // Connect to mongoDB via mongoose
  // const user = configFile['mongo.user'];
  // const pass = configFile['mongo.pass'];
  const db = configFile['mongo.dbname'];
  const url = configFile['mongo.url'] + `/${db}`;

  const options = {
    // user,
    // pass,
    name: db,
    // auth: {
    //   authSource: 'admin',
    // },
    // server: {
{'fraction_non_alphanumeric': 0.1694316978468055, 'fraction_numerical': 0.0, 'mean_word_length': 3.7312186978297164, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '718217', 'n_tokens_mistral': 931, 'n_tokens_neox': 919, 'n_words': 197}