<commit_before>'user strict';

var pkgInfo   = require('./package.json');
var path      = require('path');
var caller    = require('caller');
var konfig    = require('konfig');
var express   = require('express');
var enrouten  = require('express-enrouten');
var bootstrap = require('./lib/bootstrap');
var log       = require('bunyan').createLogger({ name: 'microservice' });

/**
 *
 */
var buildOptions = function(options) {
  var config = konfig({ path: options.configPath || './config' });

  options                 = options || {};
  options.debug           = options.debug || false;
  options.server          = config.app.server || { port: 8000 };

  options.serviceName     = config.app.microservice.server.name || pkgInfo.name;
  options.serviceBasePath = config.app.microservice.basePath || 'services';
  
  options.zookeeper       = config.app.zookeeper || { connectionString: 'localhost:2181', retry: { count: 5 } };
  options.discoverable    = options.discoverable || false;
  options.routesPath      = options.routesPath || 'controllers';
  options.callerPath      = path.dirname(caller(2));
  
  return options;
};

/**
 *
 */
module.exports = function (options) {
  var app = express();

  options = buildOptions(options);

  bootstrap(app, options);

  if (options.debug) {
    log.info(options, 'bootstrapped microservice');
  } 

  return app;
};<commit_msg>Default plus config overlay options<commit_after>'user strict';

var pkgInfo   = require('./package.json');
var path      = require('path');
var caller    = require('caller');
var konfig    = require('konfig');
var express   = require('express');
var enrouten  = require('express-enrouten');
var bootstrap = require('./lib/bootstrap');
var log       = require('bunyan').createLogger({ name: 'microservice' });

/**
 *
 */
var buildOptions = function(options) {
  var config = konfig({ path: options.configPath || './config' });

  // Default options
  options                 = options || {};
  options.server          = options.server || { port: process.env.PORT };
  options.debug           = options.debug || false;
  options.discoverable    = options.discoverable || false;
  options.routesPath      = options.routesPath || 'controllers';
  options.callerPath      = path.dirname(caller(2));
  options.serviceName     = pkgInfo.name;
  options.serviceBasePath = 'services';
  options.zookeeper       = { connectionString: 'localhost:2181', retry: { count: 5 } };

  // Return now if we have no config
  if (!config.app) {
    return options;
  }

  // Overlay config file options
  options.server          = config.app.server || { port: process.env.PORT };
  options.serviceName     = config.app.microservice.server.name || pkgInfo.name;
  options.serviceBasePath = config.app.microservice.basePath || 'services';
  options.zookeeper       = config.app.zookeeper || { connectionString: 'localhost:2181', retry: { count: 5 } };
  
  return options;
};

/**
 *
 */
module.exports = function (options) {
  var app = express();

  options = buildOptions(options);

  bootstrap(app, options);

  if (options.debug) {
    log.info(options, 'bootstrapped microservice');
  } 

  return app;
};
{'fraction_non_alphanumeric': 0.1518787496053047, 'fraction_numerical': 0.006630880959898958, 'mean_word_length': 3.269541778975741, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3965186', 'n_tokens_mistral': 970, 'n_tokens_neox': 925, 'n_words': 207}