<commit_before>var express = require('express');
var knexConfig = require('./knexfile');
var MoronModel = require('moron').MoronModel;

// Create knex instance. We use sqlite in this example project for simplicity.
var knex = require('knex')(knexConfig.development);

// Bind all MoronModels to the knex instance. If you only have one database in
// your server this is all you have to do. For multi database systems, see
// the MoronModel.bindKnex method.
MoronModel.knex(knex);

var app = express()
  .use(require('body-parser').json())
  .use(require('morgan')('dev'))
  .set('json spaces', 2);

// Register our REST API.
require('./api')(app);

// Error handling.
app.use(function (err, req, res, next) {
  if (!err) {
    return next();
  }

  if (err.statusCode) {
    res.status(err.statusCode);
  } else {
    res.status(500);
  }

  if (err.data || err.message) {
    res.send(err.data || err.message);
  } else {
    res.end();<commit_msg>simplify express example error handler<commit_after>var express = require('express');
var knexConfig = require('./knexfile');
var MoronModel = require('moron').MoronModel;

// Create knex instance. We use sqlite in this example project for simplicity.
var knex = require('knex')(knexConfig.development);

// Bind all MoronModels to the knex instance. If you only have one database in
// your server this is all you have to do. For multi database systems, see
// the MoronModel.bindKnex method.
MoronModel.knex(knex);

var app = express()
  .use(require('body-parser').json())
  .use(require('morgan')('dev'))
  .set('json spaces', 2);

// Register our REST API.
require('./api')(app);

// Error handling.
app.use(function (err, req, res, next) {
  if (err) {
    res.status(err.statusCode || 500).send(err.data || err.message || {});
  } else {
    next();
{'fraction_non_alphanumeric': 0.15789473684210525, 'fraction_numerical': 0.00443213296398892, 'mean_word_length': 3.8679245283018866, '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': '4703335', 'n_tokens_mistral': 599, 'n_tokens_neox': 578, 'n_words': 178}