<commit_before>'use strict';
var express = require('express');
var pg = require('pg');
var app = express();
var slashes = require('connect-slashes');
var env = process.env.NODE_ENV || 'development';

//Routes with our without slashes take to same place after adding slashes. False means
//slashes are removed if they are in the given url.
app.use(slashes(false));

//Enabling livereload in development
if (env === 'development') {
  app.use(require('connect-livereload')());
}

 // Setup view engine for server side templating
app.engine('.html', require('ejs').__express);
app.set('view engine', 'html');

// Setup path where all server templates will reside
app.set('views', 'server/templates');

//Static files for client
app.use(express.static('dist/client/'));
if (process.env.LUKUSEIKKAILU_EDITOR_DISABLED !== 'true') {
  app.use(express.static('dist/editor/'));
}

//Setting routes declared in routes directory
require('./server/routes/routes')(app);

//Creates database client and connect it to the database.
//If our table doesn't exist then it is created.
pg.connect(process.env.DATABASE_URL, function(err, client) {
  if (err) {
    console.log(err);
  }
  client.query('CREATE TABLE IF NOT EXISTS files(id SERIAL PRIMARY KEY, filename VARCHAR(64) NOT NULL, filesize INT NOT NULL, data BYTEA NOT NULL, created TIMESTAMP DEFAULT current_timestamp NOT NULL)');
  client.query('CREATE TABLE IF NOT EXISTS games(id SERIAL PRIMARY KEY, data JSONB NOT NULL, created TIMESTAMP DEFAULT current_timestamp NOT NULL)');
});

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  var err = new Error('Not Found');
  err.status = 404;
  console.log(req.url);
  next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
  app.use(function(err, req, res, next) {
    console.log(req.url);
    res.status(err.status || 500);
    res.render('error', {
      status: err.status,
      message: err.message,
      error: err
    });
  });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {}
  });
});

var portNumber = process.env.PORT || 3000;
var server = app.listen(portNumber, function() {

  var host = server.address().address;
  var port = server.address().port;

  console.log('Example app listening at http://%s:%s', host, port);
});<commit_msg>Fix problem occurring in Heroku deployment.<commit_after>'use strict';
var express = require('express');
var pg = require('pg');
var app = express();
var slashes = require('connect-slashes');
var env = process.env.NODE_ENV || 'development';

//Routes with our without slashes take to same place after adding slashes. False means
//slashes are removed if they are in the given url.
app.use(slashes(false));

//Enabling livereload in development
if (env === 'development') {
  app.use(require('connect-livereload')());
}

 // Setup view engine for server side templating
app.engine('.html', require('ejs').__express);
app.set('view engine', 'html');

// Setup path where all server templates will reside
app.set('views', 'server/templates');

//Static files for client
app.use(express.static('dist/client/'));
if (process.env.LUKUSEIKKAILU_EDITOR_DISABLED !== 'true') {
  app.use(express.static('dist/editor/'));
}

//Setting routes declared in routes directory
require('./server/routes/routes')(app);

//Creates database client and connect it to the database.
//If our table doesn't exist then it is created.
pg.connect(process.env.DATABASE_URL, function(err, client) {
  if (err) {
    console.log(err);
  }
  client.query('CREATE TABLE IF NOT EXISTS files(id SERIAL PRIMARY KEY, filename VARCHAR(64) NOT NULL, filesize INT NOT NULL, data BYTEA NOT NULL, created TIMESTAMP DEFAULT current_timestamp NOT NULL)');
  client.query('CREATE TABLE IF NOT EXISTS games(id SERIAL PRIMARY KEY, data JSONB NOT NULL, created TIMESTAMP DEFAULT current_timestamp NOT NULL)');
});

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  var err = new Error('Not Found');
  err.status = 404;
  console.log(req.url);
  next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
  app.use(function(err, req, res, next) {
    console.log(req.url);
    res.status(err.status || 500);
    res.render('error', {
      status: err.status,
      message: err.message,
      error: err
    });
  });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
  res.status(err.status || 500);
  res.render('error', {
    status: err.status,
    message: err.message,
    error: {}
  });
});

var portNumber = process.env.PORT || 3000;
var server = app.listen(portNumber, function() {

  var host = server.address().address;
  var port = server.address().port;

  console.log('Example app listening at http://%s:%s', host, port);
});
{'fraction_non_alphanumeric': 0.1489277204130262, 'fraction_numerical': 0.007148530579825258, 'mean_word_length': 4.160860655737705, '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': '553062', 'n_tokens_mistral': 1595, 'n_tokens_neox': 1534, 'n_words': 491}