<commit_before>'use strict';
/*
 * Generic backend Server Start Poinrt
 * 
 * Created by <NAME>
 */

/**
 * Loads the env file with dotenv library
 */
require('dotenv').config();

/**
 * Module dependencies
 */
const fs = require('fs'),
  join = require('path').join,
  express = require('express'),
  mongoose = require('mongoose'),
  passport = require('passport'),
  config = require('./config'),
  log = require('winston'),
  app = express();

/**
 * Establishes an Connection with logging on MongoDB
 * 
 * @returns {Object} an Instance of the current MongoDB Connection
 */
const connectToMongoDB = () => {
  const options = { server: { socketOptions: { keepAlive: 1 } } };
  const connection = mongoose.connect(config.db, options).connection;
  connection.on('open', () => log.info('Connected to the Database via ' + config.db));
  connection.on('error', err => log.error(err));
  return connection;
};

/**
 * Performs an Listen on a specify port
 * 
 * @param port specefies an port which will be used for the HTTP Server
 * 
 */
const listen = (port) => {
  if (app.get('env') === 'test') return;
  app.listen(port);
  log.info('Listening with Express on Port: ' + port);
};

/**
 * Initializes the complete Application
 * Including following Components:
 * - Models
 * - Passport
 * - Express
 * - Routes
 * 
 * @returns {Object} The Current Instance of the Connection
 */
const init = () => {
  const models = join(__dirname, 'app/models');
  // Bootstrap models
  fs.readdirSync(models)
    .filter(file => ~file.indexOf('.js'))
    .forEach(file => require(join(models, file)));

  // Bootstrap routes
  require('./config/passport')(passport);
  require('./config/express')(app, passport);
  require('./config/routes')(app, passport);

  // Initialize Express
  const connection = connectToMongoDB();
  const port = process.env.PORT || 3000;
  connection
    .on('error', err => log.error(err))
    .on('disconnected', connectToMongoDB)
    .once('open', () => listen(port));
  return connection;
};

/**
 * Run Initialization
 */
(() => {
  const connection = init();
  /**
   * Expose
   */
  module.exports = {
    app,
    connection
  };
})();<commit_msg>refactored options object of mongoose<commit_after>'use strict';
/*
 * Generic backend Server Start Poinrt
 * 
 * Created by <NAME>
 */

/**
 * Loads the env file with dotenv library
 */
require('dotenv').config();

/**
 * Module dependencies
 */
const fs = require('fs'),
  join = require('path').join,
  express = require('express'),
  mongoose = require('mongoose'),
  passport = require('passport'),
  config = require('./config'),
  log = require('winston'),
  app = express();

/**
 * Establishes an Connection with logging on MongoDB
 * 
 * @returns {Object} an Instance of the current MongoDB Connection
 */
const connectToMongoDB = (options) => {
  const connection = mongoose.connect(config.db, options).connection;
  connection.on('open', () => log.info('Connected to the Database via ' + config.db));
  connection.on('error', err => log.error(err));
  return connection;
};

/**
 * Performs an Listen on a specify port
 * 
 * @param port specefies an port which will be used for the HTTP Server
 * 
 */
const listen = (port) => {
  if (app.get('env') === 'test') return;
  app.listen(port);
  log.info('Listening with Express on Port: ' + port);
};

/**
 * Initializes the complete Application
 * Including following Components:
 * - Models
 * - Passport
 * - Express
 * - Routes
 * 
 * @returns {Object} The Current Instance of the Connection
 */
const init = () => {
  const options = { server: { socketOptions: { keepAlive: 1 } } };
  const port = process.env.PORT || 3000;
  const models = join(__dirname, 'app/models');
  // Bootstrap models
  fs.readdirSync(models)
    .filter(file => ~file.indexOf('.js'))
    .forEach(file => require(join(models, file)));

  // Bootstrap routes
  require('./config/passport')(passport);
  require('./config/express')(app, passport);
  require('./config/routes')(app, passport);

  // Initialize Express
  const connection = connectToMongoDB(options);
  connection
    .on('error', err => log.error(err))
    .on('disconnected', () => connectToMongoDB(options))
    .once('open', () => listen(port));
  return connection;
};

/**
 * Run Initialization
 */
(() => {
  const connection = init();
  /**
   * Expose
   */
  module.exports = {
    app,
    connection
  };
})();
{'fraction_non_alphanumeric': 0.16996137241536013, 'fraction_numerical': 0.0022722108611679163, 'mean_word_length': 3.5711318795430946, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, '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': '5843652', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1332, 'n_words': 363}