<commit_before>'use strict';

var express = require('express');
var http = require('http');
var morgan = require('morgan');
var path = require('path');
var querystring = require('querystring');
var request = require('request');
var serveStatic = require('serve-static');
var url = require('url');


var setupMiddlewares = function(app) {
  if (!process.env.NODE_ENV || process.env.NODE_ENV == 'development'); {
    app.use(morgan('dev'));
  }
};

var setupRoutes = function(app) {
  var staticRoot = path.join(process.cwd(), 'build');

  app.get('/', function(req, res) {
    res.sendFile(path.join(staticRoot, 'index.html'));
  });
  app.use('/', serveStatic(staticRoot));
};

var setupApiProxy = function(app) {
  app.use('/route', function(req, res) {
    var apiUrl = 'http://www.yournavigation.org/api/1.0/gosmore.php?' + querystring.stringify(req.query);
    req.pipe(request(apiUrl)).pipe(res);
  });
}


var setup = function() {
  var app = express();
  var httpServer = http.createServer(app);

  setupMiddlewares(app);
  setupRoutes(app);
  setupApiProxy(app);

  app.listen(process.env.PORT || 3000, function() {
    console.info('Express server started');
  });
}


setup();<commit_msg>add periodic ping to public url, to prevent heroku dyno sleeping<commit_after>'use strict';

var express = require('express');
var http = require('http');
var morgan = require('morgan');
var path = require('path');
var querystring = require('querystring');
var request = require('request');
var serveStatic = require('serve-static');
var url = require('url');


var setupMiddlewares = function(app) {
  if (!process.env.NODE_ENV || process.env.NODE_ENV == 'development'); {
    app.use(morgan('dev'));
  }
};

var setupRoutes = function(app) {
  var staticRoot = path.join(process.cwd(), 'build');

  app.get('/', function(req, res) {
    res.sendFile(path.join(staticRoot, 'index.html'));
  });
  app.use('/', serveStatic(staticRoot));
};

var setupApiProxy = function(app) {
  app.use('/route', function(req, res) {
    var apiUrl = 'http://www.yournavigation.org/api/1.0/gosmore.php?' + querystring.stringify(req.query);
    req.pipe(request(apiUrl)).pipe(res);
  });
};


var setup = function() {
  var app = express();
  var httpServer = http.createServer(app);

  setupMiddlewares(app);
  setupRoutes(app);
  setupApiProxy(app);

  app.listen(process.env.PORT || 3000, function() {
    console.info('Express server started');
  });
};

var setupPing = function() {
  var ping = function() {
    request(process.env.BASE_URL);
  };

  ping();
  setInterval(ping, 30*60*1000); // 30m
};


setup();
setupPing();
{'fraction_non_alphanumeric': 0.18759571209800918, 'fraction_numerical': 0.008422664624808576, 'mean_word_length': 4.583333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '849252', 'n_tokens_mistral': 898, 'n_tokens_neox': 853, 'n_words': 177}