<commit_before>/*jshint node:true*/
'use strict';

var koa = require('koa');
var fs = require('fs');
var path = require('path');
var extname = path.extname;

var app = koa();

var port = process.env.PORT || 8001;

var environment = process.env.NODE_ENV;

app.use(function *pageNotFound(next){
  yield next;

  if (404 != this.status) return;

  // we need to explicitly set 404 here
  // so that koa doesn't assign 200 on body=
  this.status = 404;

  switch (this.accepts('html', 'json')) {
    case 'html':
      this.type = 'html';
      this.body = '<p>Page Not Found</p>';
      break;
    case 'json':
      this.body = {
        message: 'Page Not Found'
      };
      break;
    default:
      this.type = 'text';
      this.body = 'Page Not Found';
  }
});

app.use(require('koa-static')('.dist', {}));
app.use(require('koa-static')("src/server", {}));

app.use(require('koa-router')(app));

// Handle references to app (bad template)
app.all('/app/*', function *() {
     this.status = 404;
});

// Handle references to missing api functions
app.all('/api/*', function *() {
    this.status = 404;
})<commit_msg>add comment on cheating api<commit_after>/*jshint node:true*/
'use strict';

var koa = require('koa');
var fs = require('fs');
var path = require('path');
var extname = path.extname;

var app = koa();

var port = process.env.PORT || 8001;

var environment = process.env.NODE_ENV;

app.use(function *pageNotFound(next){
  yield next;

  if (404 != this.status) return;

  // we need to explicitly set 404 here
  // so that koa doesn't assign 200 on body=
  this.status = 404;

  switch (this.accepts('html', 'json')) {
    case 'html':
      this.type = 'html';
      this.body = '<p>Page Not Found</p>';
      break;
    case 'json':
      this.body = {
        message: 'Page Not Found'
      };
      break;
    default:
      this.type = 'text';
      this.body = 'Page Not Found';
  }
});

app.use(require('koa-static')('.dist', {}));

// Cheat having a server side API by returning static data files under the server folder.
app.use(require('koa-static')("src/server", {}));

app.use(require('koa-router')(app));

// Handle references to app (bad template)
app.all('/app/*', function *() {
     this.status = 404;
});

// Handle references to missing api functions
app.all('/api/*', function *() {
    this.status = 404;
})
{'fraction_non_alphanumeric': 0.18077413866439812, 'fraction_numerical': 0.01871544023819651, 'mean_word_length': 3.0481927710843375, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6768976', 'n_tokens_mistral': 832, 'n_tokens_neox': 786, 'n_words': 221}