<commit_before>'use strict';

module.exports = main;

var koa = require('koa');
var routers = require('./routers');
var pkg = require('../package.json');

var trace = require('koa-trace');
var favicon = require('koa-favicon');
var requestId = require('koa-request-id');
var responseTime = require('koa-response-time');
var conditional = require('koa-conditional-get');
var etag = require('koa-etag');
var serve = require('koa-static');
var htmlMinifier = require('koa-html-minifier');
var printRequestId = require('./middleware/print-request-id');
var ms = require('ms');
var path = require('path');

function main() {
  var app = koa();

  trace(app);

  app.name = pkg.name;
  app.proxy = true;
  app.poweredBy = false;
  app.isProd = process.env.NODE_ENV === 'production';

  if (!app.isProd) app.debug();

  app.use(favicon(path.resolve(__dirname, '../public/images/favicon.ico')));
  app.use(conditional());
  app.use(etag());
  app.use(serve(path.resolve(__dirname, '../public'), {
    maxage: app.isProd ? ms('30 days') : 0,
    gzip: true
  }));
  app.use(requestId());
  app.use(responseTime());
  app.use(printRequestId());
  app.use(function*(next){
    this.locals = this.locals || {};
    this.locals.context = this;
    yield next;
  });

  if (app.isProd) {
    app.use(htmlMinifier({
      collapseWhitespace: true,
    }));
  } else {
    app.use(require('koa-livereload')());
  }

  routers(app);
  return app;
}

if (!module.parent) {
  main().listen(process.env.PORT || 3000);
}
<commit_msg>Allow timing API via header.<commit_after>'use strict';

module.exports = main;

var koa = require('koa');
var routers = require('./routers');
var pkg = require('../package.json');

var trace = require('koa-trace');
var favicon = require('koa-favicon');
var requestId = require('koa-request-id');
var responseTime = require('koa-response-time');
var conditional = require('koa-conditional-get');
var etag = require('koa-etag');
var serve = require('koa-static');
var htmlMinifier = require('koa-html-minifier');
var printRequestId = require('./middleware/print-request-id');
var ms = require('ms');
var path = require('path');

function main() {
  var app = koa();

  trace(app);

  app.name = pkg.name;
  app.proxy = true;
  app.poweredBy = false;
  app.isProd = process.env.NODE_ENV === 'production';

  if (!app.isProd) app.debug();

  app.use(function*(next) {
    this.set('Timing-Allow-Origin', '*');
    yield next;
  });
  app.use(favicon(path.resolve(__dirname, '../public/images/favicon.ico')));
  app.use(conditional());
  app.use(etag());
  app.use(serve(path.resolve(__dirname, '../public'), {
    maxage: app.isProd ? ms('30 days') : 0,
    gzip: true
  }));
  app.use(requestId());
  app.use(responseTime());
  app.use(printRequestId());
  app.use(function*(next){
    this.locals = this.locals || {};
    this.locals.context = this;
    yield next;
  });

  if (app.isProd) {
    app.use(htmlMinifier({
      collapseWhitespace: true,
    }));
  } else {
    app.use(require('koa-livereload')());
  }

  routers(app);
  return app;
}

if (!module.parent) {
  main().listen(process.env.PORT || 3000);
}

{'fraction_non_alphanumeric': 0.19974432726110578, 'fraction_numerical': 0.0044742729306487695, 'mean_word_length': 3.9603803486529316, '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': '3167429', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1092, 'n_words': 210}