<commit_before>/**
 * Module dependencies
 */

var dmarshal = require('annex-marshal-msgpack-node');
var metric = require('connect-metric');
var createServer = require('./server');
var createClient = require('./client');
var envs = require('envs');

module.exports = function(opts) {
  opts = opts || {};
  opts.marshal = opts.marshal || dmarshal;
  var app = createServer(opts);

  app.use(function logger(req, res, next) {
    var start = Date.now();
    res.on('end', function() {
      req.metric({
        at: 'info',
        module: req.module,
        method: req.method,
        ip: req.ip,
        service: (Date.now() - start) + 'ms',
        status: res.statusCode,
        bytes: res._headers['content-length']
      });
    })
    next();
  });
  app.use(metric((opts.metric||{}).context, (opts.metric||{}).options));

  app.durga = createClient(opts.durgaUrl || envs('DURGA_URL'),
                           opts.serviceEnv || envs('SERVICE_ENV', 'prod'),
                           opts.wsUrl || envs('WS_URL'));

  app.on('register:call', function(mod, fn) {
    if (app.durga) app.durga.register(mod, fn, 0);
  });
  app.on('register:cast', function(mod, fn) {
    if (app.durga) app.durga.register(mod, fn, 1);
  });

  return app;
};
<commit_msg>default SERVICE_ENV to development<commit_after>/**
 * Module dependencies
 */

var dmarshal = require('annex-marshal-msgpack-node');
var metric = require('connect-metric');
var createServer = require('./server');
var createClient = require('./client');
var envs = require('envs');

module.exports = function(opts) {
  opts = opts || {};
  opts.marshal = opts.marshal || dmarshal;
  var app = createServer(opts);

  app.use(function logger(req, res, next) {
    var start = Date.now();
    res.on('end', function() {
      req.metric({
        at: 'info',
        module: req.module,
        method: req.method,
        ip: req.ip,
        service: (Date.now() - start) + 'ms',
        status: res.statusCode,
        bytes: res._headers['content-length']
      });
    })
    next();
  });
  app.use(metric((opts.metric||{}).context, (opts.metric||{}).options));

  app.durga = createClient(opts.durgaUrl || envs('DURGA_URL'),
                           opts.serviceEnv || envs('SERVICE_ENV', 'development'),
                           opts.wsUrl || envs('WS_URL'));

  app.on('register:call', function(mod, fn) {
    if (app.durga) app.durga.register(mod, fn, 0);
  });
  app.on('register:cast', function(mod, fn) {
    if (app.durga) app.durga.register(mod, fn, 1);
  });

  return app;
};

{'fraction_non_alphanumeric': 0.18686473807662235, 'fraction_numerical': 0.001563721657544957, 'mean_word_length': 2.7967359050445104, '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': '4563216', 'n_tokens_mistral': 862, 'n_tokens_neox': 840, 'n_words': 169}